Pure Virtual Functions

Pure virtual functions are functions that are not implemented in the base class but must be implemented in a concrete derived class.

A pure virtual function is declared as follows:

void plot() const = 0;

Having at least one of these will make your class abstract, i.e. it cannot be instantiated.

We can model interfaces in C++ using abstract classes. An interface is a specification that will be fully implemented in derived classes. It is simply implemented as an abstract class that has only pure virtual functions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.