Object-oriented programming (OOPs) Question:

Download Job Interview Questions and Answers PDF

What is pure virtual function in OOP?

OOP Interview Question
OOP Interview Question

Answer:

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
};

Download OOP Interview Questions And Answers PDF

Previous QuestionNext Question
What is Public access modifier in C#?When to Use Abstract Classes and When Interfaces.