Virtual function nature

Virtual function is essentially a function pointer

Friend function can not be declared the virtual function, the virtual function as a friend of another class.

 

The constructor can not be virtual, if declared as virtual functions: No structure again, there is no way to create a subclass of parent class object

 

Virtual destructor, so that the release of the correct parent pointer memory object subclasses: subclass destructor first call, and then call the parent class destructor

 

Pure virtual function

Containing pure virtual function class is an abstract class, an abstract class is not instantiated objects, pointers can be defined to provide different functions to perform the same interface;

An abstract class can not function as a return value and parameters of the abstract class pointer. Can be achieved adapter mode

All interfaces are implemented before they can instantiate, as long as one does not implement the interface is an abstract class .

 

Guess you like

Origin www.cnblogs.com/xiangtingshen/p/11617070.html