C++: Inheritance Flashcards

1
Q

What do classes gain access to when they inherit from other classes?

A

The public and protected objects and methods of the parent class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How is inheritance defined in C++?

A

class derived-class-name: access-specifier base-class-name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the access specifier affect?

A

The access specifier interacts with those used in the parent class and effect which attributes and methods the child class can have access to.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the diamond problem?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you resolve the Diamond Problem?

A

Using Virtual Classes, or applying the scope resolution operator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an example of an observer pattern?

A

Publish and Subscribe

How well did you know this?
1
Not at all
2
3
4
5
Perfectly