Answers

Question and Answer:

  Home  OOP

⟩ What is pure virtual function in OOP?

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"

syntax:

class Base {

public:

void f1(); // not virtual

virtual void f2(); // virtual, not pure

virtual void f3() = 0; // pure virtual

};

 234 views

More Questions for you: