9-Inheritance & Polymorphism Flashcards

1
Q

Order of constructor and destructor calling in class heriechy

A

const: goes up and, then down
const: down, and then up (reverse order)

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

Destructor of a class with virtual functions

A

a class that contains virtual functions should also contain a virtual destructor: To ensure that the correct srequence of destructors is called.

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

Why virtual functions and polymophism

A

Provide Dynamic binding: This allows the program to choose appropriate method of a particular object (not pointer) type at runtime.

    • virtual function (for Vtable)
    • pointer

Polymorphism: requirers overriding base class methods and using virtual functions

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