MULTILEVEL INHERITANCE
AIM:
A program to illustrate multilevel inheritance. we have three classes, student, test and result. Here class student is the base class. And the class test is derived from the base class student. And the another class result is derived from the class test.
ALGORITHM:
• Start the process
• Invoke the base class student
• Invoke the derived class test which in inherited by the class student
• Invoke the derived class result which in inherited by the class test
• Create an object student1 for the result class
• Call student1.getno(),assign the value of rno in student class
• Call student1.getmarks(),assign the marks in test class
• Call student1.display(),for displaying the result
• Stop the process
PROGRAM
#include#include class student { protected: int rno; public: void getno(int); void putno(void); }; void student::getno(int a) { rno=a; } void student ::putno() { cout<<"rollno="< 13 thoughts on “C++ program to illustrate Multilevel Inheritance”
Leave a Reply
if derived class 2 is inherited privately!!!
then
can we make an object of that class (derived class 2) in the MAIN() ?????
Why you have not wrote the header file like this?
#include
#include
can any explain there example mechanism?