Code:
#include
#include
class
student
{
protected:
char name[20],dept[20];
public:
virtual void get()=0;
virtual void show()=0;
};
class
engineering:public student
{
public:
void get()
{
cout<<"\n***Engineering
Student***";
cout<<"\n\nEnter name of
the student:";
cin>>name;
cout<<"\nEnter
department:";
cin>>dept;
}
void show()
{
cout<<"\n\nDATA";
cout<<"\nName:"<
cout<<"\nDepartment:"<
}
};
class
medicine:public student
{
public:
void get()
{
cout<<"\n***Medicine Student***";
cout<<"\n\nEnter name of the student:";
cin>>name;
cout<<"\nEnter department:";
cin>>dept;
}
void show()
{
cout<<"\n\nDATA";
cout<<"\nName:"<
cout<<"\nDepartment:"<
}
};
class
science:public student
{
public:
void get()
{
cout<<"\n***Science Student***";
cout<<"\n\nEnter name of the student:";
cin>>name;
cout<<"\nEnter department:";
cin>>dept;
}
void show()
{
cout<<"\n\nDATA";
cout<<"\nName:"<
cout<<"\nDepartment:"<
}
};
void
main()
{
clrscr();
int i;
student *s[3];
s[0]=new engineering;
s[1]=new medicine;
s[2]=new science;
for(i=0;i<3 i="" o:p="">3>
{
s[i]->get();
}
for(i=0;i<3 i="" o:p="">3>
{
s[i]->show();
}
getch();
}
No comments:
Post a Comment