![]() |
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++. How to Create a Pure Virtual Function 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. C++ Program to Implement a Pure Virtual FunctionC++
Output
Derived class implementing the pure virtual function. This is a non-pure virtual function. |
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |