![]() |
VOOZH | about |
In C++, pure virtual functions are those functions that are not implemented in the base class. They are instead implemented in the derived classes if necessary. In this article, we will discuss how to create a pure virtual function in a class in C++.
To declare a member function as a pure virtual function, we can use the following syntax:
virtual function_name (arguements) {} = 0;
Classes that contain at least one pure virtual function are called abstract classes. If we don't implement the pure virtual function in the derived class, then the derived class also becomes the abstract class and we cannot instantiate it.
Derived class implementing the pure virtual function. This is a non-pure virtual function.