A pure virtual function is defined to implement an interface and act as a standard. programmers who inherit this class must implement this function.
To implement pure virtual functions in the base class, add "= 0" after the function prototype"
Virtual void funtion1 () = 0
In many cases, it is unreasonable for the base class to generate objects. For example, an animal can be derived from sub-classes such as tigers and peacocks as a base class, but the object generated by the animal itself is obviously unreasonable.
To solve the above problem, the concept of pure virtual function is introduced, and the function is defined as a pure virtual function (method: Virtual returntype function () = 0 ;), the compiler requires that the class must be rewritten to implement polymorphism. Classes that contain pure virtual functions are called abstract classes and cannot generate objects.
The class that declares pure virtual functions is an abstract class. Therefore, you cannot create a class instance, but only an instance of its derived class.
Differences between virtual functions and pure virtual functions