PROGRAM TO SHOW ARRAY OF OBJECTS

/*PROGRAM TO SHOW ARRAY OF OBJECTS*/

#include<conio.h>

#include<iostream.h>

#include<stdio.h>

class arr_object

{

char name[10];

public:

void input(int);

void output(int);

};

void arr_object::input(int i)

{

cout<<“Enter “<<i+1<<” name: “;

gets(name);

}

void arr_object::output(int i)

{

cout<<i+1<<” Name is: “<<name<<endl;

}

void main()

{

int i;

arr_object a[5];

clrscr();

for(i=0;i<5;i++)

{

a[i].input(i);

}

cout<<“Entered names are:\n”;

for(i=0;i<5;i++)

{

a[i].output(i);

}

getch();

}

Leave a Reply

Your email address will not be published. Required fields are marked *