Advertisement



< Prev
Next >



C++ Multiple Inheritance




In our previous article, we introduced you to one of the types of inheritance in C++ i.e. single inheritance. Today we are going to discuss another type of inheritance named - multiple inheritance.

Multiple inheritance is performed when a class inherits the features of multiple classes(more than one class at a time).



The class that wants to use the features of another class is called subclass or derived class, whereas the class whose features are to be used/inherited is referred to as base class.




What features a subclass inherits from its base class, through inheritance?



Note - Base class members marked with private visibility mode are never inherited.




Rules of inheritance -


Depending on the value of visibility-mode, multiple inheritance can be performed in various ways -




Syntax of Multiple Inheritance


Let us take a look at the syntax of performing multiple inheritance, using which we could define a derived class which is inheriting multiple base classes.

class derived-class-name : visibility-mode base-class-name1, visibility-mode base-class-name2...
{
//members of derived class
}





Advertisement




Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement