Type of Inheritance
Type of Inheritance
- Multiple inheritance
When a derived class is the base of another class, it is multiple inheritances.
E.g.
Class base A
{
—————
—————-
};
Class derived B: public base A
{
——————-
——————–
};
Class derived C: public derived B
{
—————–
——————
};
- Hybrid inheritance
When a class inherits from multiple base classes and all of its base classes are subclasses of the same class, it is called hybrid inheritance.
E.g.
Class base A
{
—————–
—————–
};
Class derived B: public base A
{
————–
—————
};
Class derived C: public base A
{
—————
—————
};
Class derived D: public derived B, public derived C
{
————–
————–
};
- Hierarchical inheritance
When many subclasses inherit from a single base class, it is known as hierarchical inheritance.
E.g.
Class base A
{
—————
—————
};
Class derived B: public base A
{
—————-
—————-
};
Class derived c: public base A
{
———-
———-
};
Class derived D: public base A
{
————
————
};
Related posts:
- Inheritance in C++ Inheritance in C++ Inheritance is one of the most important...
- C++ Base Class Type of base classes in C++ A base class can...
- Derivation in C++ Types of derivation Inheritance is a process of creating a...
- Array of class objects Array of class objects and single inheritance A program consisting...
- Class Hierarchies Class Hierarchies The relationship between a base ad derived classes...