Like Us On Facebook

Follow Us On Twitter

Drop Down Menu

Wednesday 24 April 2013

Inheritance And Its Types In C++

The basic meaning of Inheritance is using a pre-defined code. This is the main advantage in Object oriented Programming (OOPS), where one can use a code that has been previously written and defined but with the condition that the code is used as-is or in other words, we are not changing the code.
All the pre-defined code is used resides into classes. To use those codes, we use a feature called inheritance, whereby, we "inherit" those classes.
The class from which other class inherits is called as Parent or Base Class and the class that inherits is called as Child or Derived Class.
 

Types Of Inheritances:
There are 5 types of Inheritances used in C++:
1) Single Inheritance
2) Multilevel Inheritance
3) Hierarchial Inheritance
4) Hybrid Inheritance
5) Multiple Inheritance

As Shown in Figure:

Types Of Inheritance C++

Accessibility Modes in Inheritance in C++:
We can use the following table to understand the accessibility of the members in different modes of Inheritance:

Accessibility Modes in Inheritance C++

Here, by 'X' we mean that, that object is not inheritable. Remember, Private objects and functions are never inherited. I'll be discussing about these types of inheritances individually in my next post.



Do you like this post? Please link back to this article by copying one of the codes below.

URL: HTML link code: Forum link code: