C++ | Virtual Functions | Question 1
Which of the following is true about virtual functions in C++.
(A) Virtual functions are functions that can be overridden in derived class with the same signature.
(B) Virtual functions enable run-time polymorphism in a inheritance hierarchy.
(C) If a function is ‘virtual’ in the base class, the most-derived class’s implementation of the function is called according to the actual type of the object referred to, regardless of the declared type of the pointer or reference.
In non-virtual functions, the functions are called according to the type of reference or pointer.
(D) All of the above
Answer: (D)
Explanation: See http://en.wikipedia.org/wiki/Virtual_function
Quiz of this Question
Recommended Posts:
- C++ | Virtual Functions | Question 3
- C++ | Virtual Functions | Question 13
- C++ | Virtual Functions | Question 11
- C++ | Virtual Functions | Question 4
- C++ | Virtual Functions | Question 2
- C++ | Virtual Functions | Question 7
- C++ | Virtual Functions | Question 5
- C++ | Virtual Functions | Question 6
- C++ | Virtual Functions | Question 14
- C++ | Virtual Functions | Question 14
- C++ | Virtual Functions | Question 9
- C++ | Virtual Functions | Question 10
- C++ | Virtual Functions | Question 12
- Can virtual functions be inlined?
- Can virtual functions be private in C++?



