Question:medium

What is the correct syntax for declaring a pure virtual function in C++?

Show Hint

The syntax= 0` is called a pure specifier, and it's what distinguishes a pure virtual function from a regular virtual function.
Updated On: Jul 2, 2026
  • void virtual show () = 0
  • void show () virtual
  • virtual void show () = 0
  • pure virtual void show ()
Show Solution

The Correct Option is C

Solution and Explanation

Step 1: Recall the goal of a pure virtual function.
A pure virtual function deliberately has no body in the base class, it exists only to force every derived class to supply its own implementation, and that is what makes the base class abstract.
Step 2: Learn the exact syntax rule.
The keyword virtual must appear first, right before the return type, followed by the normal function signature, and the declaration is then closed with an equals sign and a zero instead of a function body.
Step 3: Apply the rule to each option.
Placing virtual after the return type or after the parameter list breaks this grammar, and pure virtual is not a real keyword pairing in C++, so the only line following the correct pattern is virtual void show () = 0.
\[ \boxed{\text{virtual void show () = 0}} \]
Was this answer helpful?
0