//Single Inheritance
#include<iostream.h>
#include<conio.h>
class ABC
{
protected:
char name[15];
int age;
};
class abc:public ABC //Public Derivation
{
float height;
float weight;
public:
void getdata()
{
cout<<"Enter Name and Age\n";
cin>>name>>age;
cout<<"Enter Height and Weight\n";
cin>>height>>weight;
}
void show()
{
cout<<"\nName="<<name<<endl;
cout<<"Age="<<age<<endl;
cout<<"Height="<<height<<endl;
cout<<"Weight="<<weight<<endl;
}
};
void main()
{
clrscr();
abc x;
x.getdata();
x.show();
getch();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.