Which of the following is the correct syntax to declare a Pure Virtual Function?
-
virtual void print()=0;
-
virtual void print=0 ()
-
virtual void print()={0}
-
virtual void print()=(0)
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.