Multiple choice

Which of the following is the correct syntax to declare a Pure Virtual Function?

  1. virtual void print()=0;

  2. virtual void print=0 ()

  3. virtual void print()={0}

  4. virtual void print()=(0)

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

A pure virtual function is a function that has no body in the base class. To declare a function as virtual we just have to add 'function() = 0' in the function declaration. A class that contains at least one pure virtual function is called an 'abstract' class and it cannot be instantiated.