#include<iostream.h>
#include<conio.h>
class studentbase
{
public:
int roll,height,weight;
char name[20],gender;
void getdata()
{
cout<<"Enter Student Details:";
cout<<"\n\tRoll No :";
cin>>roll;
cout<<"\tName :";
cin>>name;
cout<<"\tGender(M or F) :";
cin>>gender;
cout<<"\tHeight(in cm) :";
cin>>height;
cout<<"\tWeight(in Kg) :";
cin>>weight;
}
};
class studderived:public studentbase
{
public:
void disp()
{
clrscr();
cout<<"\n\t\tStudent Details";
cout<<"\n\t\t*-*-*-*-*-*-*-*";
cout<<"\n\n\t Name : "<<name;
cout<<"\n\t RollNo.: "<<roll;
cout<<"\n\t Gender : "<<gender;
cout<<"\n\t Height : "<<height<<" cm";
cout<<"\n\t Weight : "<<weight<<" Kg";
}
};
void main()
{
studderived s;
clrscr();
s.getdata();
s.disp();
getch();
}
No comments:
Post a Comment