Inheritance in C++

If you're familiar with Java, it's like the "extends" keyword.
Inheritance allows you to make a class that's based off another class known as the base class; a "Cat" class could inherit from a "Mammal" class (the Mammal class is the base of the Cat class), which would inherit from an "Animal" class, and so forth.
A class can access the protected and public members of its base class, but not the private members.
 
In inheritance, the class derived from the class above it inherits all the datamembers and functions of the class above it, and either uses them the same, or has it's own implementation of it.
 
Inheritance is like copying all the stuff in the super classes into a new class, renaming it and then using it. Inheritance is there to avoid copying and pasting your preexisting code, in other words, to promote code reuse.
 
Inherited classes get all the properties of the parent. Also we can include new properties that are not in the parent.
 
Acquiring the properties of classes r class from other classes r class.
 
Back
Top