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.

Computer Science & Information Technology

You might also like to view...

To what is the Rabin-Karp algorithm most similar to?

a. Naive search b. Boyer-Moore algorithm c. Knuth-Morris-Pratt algorithm d. Aho-Korasick algorithm

Computer Science & Information Technology

For an ascending sort, you need to perform the swap() method whenever any given element of the score array has a lower value than the next element.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

There are three normal forms; however, the majority of database designs only require the first two normal forms

Indicate whether the statement is true or false

Computer Science & Information Technology

You can turn off grammar checking by ____.

A. pressing [F7] B. clicking the Check grammar check box to remove the checkmark C. opening the AutoCorrect Exceptions dialog box D. opening the AutoCorrect dialog box

Computer Science & Information Technology