Multilevel Inheritance


The process of deriving a new class from an already existing class and than again derive a new class from previously derived class is known as multilevel inheritance.

Multilevel Inheritance

     

#include<iostream.h>
class college
{
char name[20];
public:
void inputcl()
{
cout<<"Enter College Name:";
cin>>name;
}
void outputcl()
{
cout<<"Name:"<<name<<endl;
}
};
class branch:public college
{
char BranchName[20];
int intake;
public:
void inputbr()
{
cout<<"Enter Branch Name:";
cin>>BranchName;
cout<<"Enter Intake:";
cin>>intake;
}
void outputbr()
{
cout<<"Branch Name:"<<BranchName<<endl;
cout<<"Intake:"<<intake<<endl;
}
};
class student:public branch
{
int rollno;
char stname[20];
public:
void inputst()
{
cout<<"Enter Roll Number:";
cin>>rollno;
cout<<"Enter Name:";
cin>>stname;
}
void outputst()
{
outputcl();
outputbr();
cout<<"Roll Number:"<<rollno<<endl;
cout<<"Name:"<<stname<<endl;
}
};
int main()
{
student S1;
S1.inputcl();
S1.inputbr();
S1.inputst();
S1.outputst();
return 0;
}

Download Projects


Download Programs