Answer the following questions true (T) or false (F)
1. In a class, functions declared with the virtual keyword need not be defined.
2. The virtual function mechanism binds the “right” function to objects.
1. False
Explanation: There is a table set up by C++ that needs to know where the function definition is located. If you did not supply one, there will be an error message and the compilation will abort. The error message may not be particularly clear. My compiler complains about ‘missing virtual table’. Non-virtual functions can always be declared but no defined, unless you call them, that is). There is an exception to this: pure virtual functions, in which the body of the function is replaced by =0.
2. True
Explanation: The mechanism is to build a table that is filled in partly at compile time and partly at runtime, then it is read at runtime to decide which function to call.
You might also like to view...
The ________ is the screen display through which a user communicates with the software installed on a drive
Fill in the blank(s) with correct word
Data items whose values do not change while the program is running are
a. literals b. variables c. characters d. integers e. None of these