#include<iostream.h>
#include<conio.h>
class person
{
private:
char name[20];
long int phno;
public:
void read()
{
cout<<"\n Enter name ";
cin>>name;
cout<<"\n Enter Phno.=";
cin>>phno;
}
void show()
{
cout<<"\n Name="<<name;
cout<<"\n Phone="<<phno;
}
};
{
private:
int rollno;
char course[20];
public:
void read()
{
person::read();
cout<<"\n Enter Roll No.=";
cin>>rollno;
cout<<"\n Enter Course=";
cin>>course;
}
void show()
{
person ::show();
cout<<"\n Roll No.="<<rollno;
cout<<"\n Course="<<course;
}
};
{
private:
char dept_name[10];
char qual[10];
public:
void read()
{
person::read();
cout<<"\n Enter dept_name andQualification=";
cin>>dept_name>>qual;
}
void show()
{
person::show();
cout<<"\n Departement="<<dept_name;
cout<<"\n Qualififcation="<<qual;
}
};
main()
{
clrscr();
student s1;
cout<<"\n************************ Enter student Information******************";
s1.read();
cout<<"\n************************ Displaying Student Information*************";
s1.show();
teacher t1;
cout<<"\n************************** Enter Teacher Information*****************";
t1.read();
cout<<"\n*****************************Displaying Teacher Information************";
t1.show();
getch();
}
----------------------------------
When two or more classes are derived from a single
base class, then
Inheritance is called the hierarchical inheritance. The
representation
of the hierarchical inheritance is shown in the
following Fig.
----------------------------------
Hierarchical Inheritance
When two or more classes are derived from a single
base class, then
Inheritance is called the hierarchical inheritance. The
representation
of the hierarchical inheritance is shown in the
following Fig.
than you very much
ReplyDeleteInheritance in C++
ReplyDeleteThanks for this article
Inheritance in C++
ReplyDeleteThanks for this post, keep sharing