diff --git a/Multilevelinheritance.cpp b/Multilevelinheritance.cpp new file mode 100644 index 0000000..1025b15 --- /dev/null +++ b/Multilevelinheritance.cpp @@ -0,0 +1,73 @@ + +#include +using namespace std; +class person +{ +private: + char name[15], address[15]; +public: + void getdata() + { + cout<<"\nEnter Name: "; + cin>>name; + cout<<"\nEnter address: "; + cin>>address; + } + void showdata() + { + cout<>empID; + } + void showdata() + { + person::showdata(); + cout<>qual; + } + void showdata() + { + employee::showdata(); + cout<<"\nQualification: "< + +using namespace std; + + + +class base { + +public: + + virtual void print() + + { + + cout << "print base class" << endl; + + } + + + + void show() + + { + + cout << "show base class" << endl; + + } +}; + + + +class derived : public base { + +public: + + void print() + + { + + cout << "print derived class" << endl; + + } + + + + void show() + + { + + cout << "show derived class" << endl; + + } +}; + + + +int main() +{ + + base* bptr; + + derived d; + + bptr = &d; + + + + // virtual function, binded at runtime + + bptr->print(); + + + + // Non-virtual function, binded at compile time + + bptr->show(); +} +