Tuesday, 2 July 2013

Write a program to show the concept of Array of Object in C++

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
class biodata
{
    public:
    char name[20];
    int roll;
    public:
    void get()
    {
        cout<<"enter name and roll no. "<<"\n";
        cin>>name>>roll;
    }
    public:
    void put()
    {
        cout<<name<<setw(4)<<roll;
        cout<<"\n";
    }
};

void main()
{
int i,j;
cout<<"enter no. of entries";
cin>>j;
class biodata obj[20];
for (i=1; i<=j ; i++)
{
    obj[i].get();
}
cout<<"\n";
for (i=1; i<=j ; i++)
{
    obj[i].put();
}
}
       

No comments:

Post a Comment