Multiple choice

Which of the following is/are the valid rules for declaring a virtual function in C++?

  1. A virtual function must not be static.

  2. Destructor cannot be declared as virtual, but constructor can be declared as virtual.

  3. A virtual function may be declared as a friend for another class.

  4. Both 1 and 2

  5. Both 1 and 3

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

Options 1 and 3 are correct. Option 2 is not correct because destructor can be declared as virtual, but constructor cannot be declared as virtual.