Inheritance:
One of the most important concepts in object-oriented programming is that of inheritance. Inheritance is the process of transmitting properties of one class into another. Class which is giving properties is called "Super class" and class which is acquiring the properties is called "Sub class".Super class can be called as "Base class" or "Parent class" or "Ascendent class".
Sub class can be called as "Derived class" or "Child class" or "Descendent class".
So, The derived classes have all the features of the base class and the programmer can choose to add new features specific to the newly created derived class.
Importance of Inheritance
Inheritance was added in C++ for many reasons:Code Re-usability: Inheritance helps us reduce the amount of code and the number of lines of code we have to write. If we want creating a class, instead of writing completely new data members and member functions, the programmer can designate that the new class should inherit the members of an existing class.
Things those are not inherited
- Constructor
- Destructor
- Copy constructor
- Assignment operator
- friendship
No comments:
Post a Comment