Advertisement



< Prev
Next >



C++ Multiple Inheritance




In our previous article, we introduced you to one of the types of inheritance - single inheritance. Today we are going to discuss the first type of inheritance in C++ 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 classes whose features are to be used/inherited is referred to as base classes.




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

PYTHON and DJANGO


Advertisement