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();
}
}
       

Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart