WEB DEVELOPER SITE
PYTHONPHPJAVA
 

C++ Inheritance


Inheritance is one of the most important concepts of object-oriented programming(OOP). Inheritance allows us to define a class based on another class. This facilitates greater ease in creating and maintaining an application.
The idea of inheritance implements the is a relationship. For example, mammal IS-A animal, dog IS-A mammal, hence dog IS-A animal as well.

Syntax

Son class from the Father class.
class Son : public Father
{
 public: 
  Son() {};
};

all public members of the Father class become public members of the Son class.

A derived class inherits all base class methods with the following exceptions:

  • Constructors, destructors
  • Overloaded operators