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)
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.
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