My 2 Cents Pure Virtual Functions

Swati Mishra

Content Writer
A function with no body is called the pure virtual function. The virtual function of base class is not used. If we take the example of employee class the calc_net_salary () is never invoked. Because employee belongs to two category (confirmed /trainee), and the net salary is depends on it then the functions is derived class are always invoked. In this condition the body of virtual function may not define by the base class. This is done by adding the notation ‘=0’ to the virtual function declaration, which is described below

Example

Virtual int calc_net_salary () =0;
Above function is declared as the pure virtual function.
 
Top