What is pure virtual function?

 Posted by Charugoel on 2/4/2009 | Category: OOPS Interview questions | Views: 11358

When you define only function prototype in a base class without and do the complete implementation in derived class. This base class is called abstract class and client won’t able to instantiate an object using this base class.

A pure virtual function is a function that must be overridden in a derived class and need not be defined. A virtual function is declared to be "pure" using the curious "=0"
class Base {
void f1(); // not virtual
virtual void f2(); // virtual, not pure
virtual void f3() = 0; // pure virtual

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response