Answer the following statements true (T) or false (F)
1. Only member functions can be virtual.
2. Destructors are automatically virtual.
3. A the binding of virtual function is done at runtime if called using an object.
4. Upcasting causes no problems:
5. Downcasting causes the slicing problem.
1. True
Constructors cannot be virtual. Destructors may be virtual, indeed probably ought to be virtual, in spite of different name for different inheritance levels.
2. false
They are not virtual unless you include the modifier “virtual” in the destructor declaration.
3. True
If the binding can be done at compile time, compiler is smart enough to avoid the overhead of the virtual table.
4. false
It is legal but produces the slicing problem.
5. false
A downcast is the conversion of a Base* to a Derived*, where the derivation of Derived from Base is pubic. It requires the dynamic_cast. It is used when the client programmer hopes the Base* points to an object that really is a Derived object. Downcasting is dangerous. For further discussion of this topic see the text on page 649.