Question:easy

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

The Correct Option is D

Solution and Explanation

Step 1: Marking a member function with $= 0$ makes it pure virtual, meaning the class promises the interface but leaves the body to derived classes.

Step 2: A class holding at least one such unfinished function is incomplete as a concrete type, so it is labelled abstract.

Step 3: The direct consequence is that you cannot write an object of it; attempting to instantiate it is a compile error. You may still use pointers or references to it.

Step 4: It can absolutely be inherited, is not required to be final, and does not force a private constructor. Only when a subclass implements all pure virtual functions does that subclass become instantiable.

\[\boxed{\text{It becomes an abstract class and cannot be instantiated}}\]
Was this answer helpful?
0