C++: Inheritance Flashcards
What do classes gain access to when they inherit from other classes?
The public and protected objects and methods of the parent class
How is inheritance defined in C++?
class derived-class-name: access-specifier base-class-name
What does the access specifier affect?
The access specifier interacts with those used in the parent class and effect which attributes and methods the child class can have access to.
What is the diamond problem?
A situation where a base class inherits from two classes, which both inherit from the same super class causing a diamond structure and the base class to have two instances of the super class.
How do you resolve the Diamond Problem?
Using Virtual Classes, or applying the scope resolution operator.
What is an example of an observer pattern?
Publish and Subscribe