Posts

Showing posts with the label Multilevel

Multiple, Multilevel, Hybrid and Hierarchical inheritance

Image
Multiple inheritance:                          Multiple inheritance is a type of inheritance in c++ in which a class can be inherited from more than one classes. In this case the inherited class has more than one parent class. Multiple inheritance example:         #include <iostream> using namespace   std; class Animal { public:    Animal(){ cout<<" Animal's constructor "<<endl;} }; class Mammal { public:    Mammal(){cout<<" Mammal's constructor "<<endl;} }; class Bat : public Animal,public Mammal { public:   Bat(){ cout<<" Bat's constructor "<<endl;} }; int main(){     Bat bat1;    return 0; } Output: Animal's constructor Mammal's constructor Bat's constructor Multilevel inheritance:            In multilevel inheritance a class can be derived from another class who is already def...