PART 1
-
Why do we need inheritance in C++?
To have objects inherit properties of other objects so that things don’t need to be redefined. -
Give a simple example of objects in the real world that could be modeled in C++ using inheritance.
Fruit-> Apple/orange
PART 2
-
What is a superclass and what is a subclass?
The class being inherited from is the superclass and the class inheriting properties is a subclass -
How would you write a public inheritance in C++?
class Subclass: public Superclass
{
}; -
In what ways can a subclass extend the functionality of a superclass?
It inherits its functions and variables. So a “baseball player” class that inherits “person” class functionality can do things such as getName() from the person class.