Question:

What happens if a class contains at least one pure virtual function?

Show Hint

One pure virtual function makes the class abstract, so no direct objects can be created.
Updated On: Jul 2, 2026
  • It must be defined as final
  • It cannot be inherited by other classes
  • It forces the base class constructor to be private
  • It becomes an abstract class and cannot be instantiated
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

Step 1: A pure virtual function is declared with the =0 specifier, for example virtual void f() = 0;. It has no complete implementation the class must supply.

Step 2: Any class that declares even one such function is called an abstract class. Because part of its interface is unimplemented, the compiler will not allow you to create an object of that class directly.

Step 3: An abstract class is still very useful. Other classes can inherit from it, and a derived class becomes concrete only when it overrides every pure virtual function.

Step 4: Checking the options, the class is not forced to be final, it can still be inherited, and its constructor is not forced private. The correct effect is that it becomes an abstract class and cannot be instantiated, option (D).
Was this answer helpful?
0
0