Advertisement



< Prev
Next >



C++ Single Inheritance




In our previous article, we introduced you to the concept of inheritance and its various types. Today we are going to discuss the first type of inheritance in C++ named - single inheritance. Single inheritance is performed when a class inherits the features of another class.

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.




Syntax of Single Inheritance


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




class derived-class-name : visibility-mode base-class-name
{
//members of derived class
}







Types of Single Inheritance


Depending on the value of visibility-mode, single inheritance can be performed in two ways -




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


Advertisement