Inheritance
This lesson discusses inheritance in detail as well as constructors in derived and base classes
We'll cover the following
What is Inheritance
-
Provides a way to create a new class from an existing class.
-
New class is a specialized version of the existing class.
-
Allows the new class to overload methods from the existing class.
Terminology
- Base Class(or Parent): inherited by child class.
- Derived Class(or child): inherits from base class.
Characteristics
A derived class has:
- All members defined in the derived class.
- All members declared in the base class.
A derived class can:
- Use all
public
members defined in the derived class. - Use all
public
members defined in the base class. - Override an inherited member
A derived class cannot:
- Inherit constructors and destructors
- Change the definition of an inherited member
Notation
Let’s take a look at the notation for these two types.
Get hands-on with 1400+ tech skills courses.