* /program to illutrate multilevel inheritance./ *
#include < iostream > using namespace std;
class student
{
protected: int roll;
public: void getdata(int);
void putdata(void);
};
void student::getdata(int a)
{
roll = a;
}
void student::putdata()
{
cout << "\nrollno:" << roll;
}
class test: public student
{
protected: float sub1;
float sub2;
public: void get(float, float);
void put(void);
};
void test::get(float x, float y)
{
sub1 = x;
sub2 = y;
}
void test::put()
{
cout << "\n'c' marks:" << sub1;
cout << "\n'c++' marks:" << sub2;
}
class result: public test
{
float total;
public: void display(void);
};
void result::display(void)
{
total = sub1 + sub2;
putdata();
put();
cout << "\ntotal=" << total;
}
int main()
{
result stu;
stu.getdata(150);
stu.get(78.0, 65.8);
stu.display();
return 0;
}There is confusion between multi-level or multiple inheritence.
