C++ PROGRAMMING

Multilevel Inheritance programming in c++

 

MULTILEVEL INHERITANCE ON C++

MULTILEVEL INHERITANCE ,c++

Advance programming

THIS PROGRAM IS BASED UPON MULTILEVEL INHERITANCE

SO LETS START FROM THERE.

#include<stdio.h>
#include<conio.h>
class Super1
{
protected:
int sup_b;
public:
super()
{
cout <<“\n In Super 1”;
cout <<“\nEnter b :”; cin >>sup_b;
}
void display()
{
cout <<“\nSuper class membres”;
cout <<“\n sup_b=”<<sup_b;
}
~Super1()
{
cout <<“\nDestroying Super1″;
}
};
class Sub_Level 1 :public Super1
{
protected:
long factorial;
public:
sub_Level()
{
factorial();
}
void factorial();
void display()
{
display();
cout <<\nFactorial of” <<sup_b<<” = ” <<fabtorial;
}
{
cout <<“\nDestroying Level 1”; } }; void Sub_Level ::factorial1() { factorial = 1; int m = sup_b; while(m>0)
{
factorial = factorial *m;
m=m-1;
}
}
class sublevel2:Sub_Level1
{
long doublefact;
long doublenum;
public:
sublevel2()
{
doublefact;
doublenum = sup_b*2;
}
void displayfactorialvalues()
{
display factorial();
cout <<“\nDouble Factorial = ” << doublefact;
cout <<“\nDouble sup_b = “<< doublenum;
}
{
cout << “\nDestroying Level 2” ;
}
};
void main()
{
clrscr();
sub level2 sl2;
sl2 . displayfinalvalues();
}

IN C++ YOUR OUTPUT IS
In super 1
Enter b : 7
Super class member
sup_b = 7
factorial 1 of 7 = 5040
double factorial = 10080
double sub_b = 14
destroying level 2
destroying level 1
destroying super 1
So this is your output of this programming
Do its your self.