Pure Virtual Functions
Generally a function is declared virtual inside a base class and we redefine it the derived classes. The function declared in the base class seldom performs any task.
The following program demonstrates how a pure virtual function is defined, declared and invoked from the object of a derived class through the pointer of the base class. In the example there are two classes employee and grade. The class employee is base class and the grade is derived class. The functions getdata ( ) and display ( ) are declared for both the classes. For the class employee the functions are defined with empty body or no code inside the function. The code is written for the grade class. The methods of the derived class are invoked by the pointer to the base class.
#include
"pure virtual functions in C++ programming examples"
"pure virtual functions in C++ programming language"
"pure virtual function in c++ program"
"pure virtual function in C++"
"pure virtual function in C++ use"
"pure virtual function in C++ example"