A base class usually defines any function that needs to be redefined as a virtual function. Virtual only appears in the member function declaration within the class, and cannot appear outside the class definition body. Virtual is used to start dynamic binding.
Generally, virtual destructor must be defined for the root class at the inheritance level.
A derived class generally redefines the inherited virtual function. If the derived class does not redefine a virtual function, use the version defined in the base class. When a derived class redefinition of a virtual function, you can use virtual reserved words, but not required.
A derived class object consists of multiple parts: A member defined by the derived class and a sub-object composed of base class members. The class can access the public protected members of its base class, it is as if the members are members of the derived class.
Inherited type
Public: The base class members maintain their own access level. The Public Member of the base class is the Public Member of the derived class, and the protected member of the base class is the protected member of the derived class.
Protected: the public and protected members of the base class are all protected members in the derived class.
PRIVATE: all the members of the base class are private members in the derived class.
By default, the inherited class is private, and the inherited struct is public by default.
Classes that contain one or more pure virtual functions are abstract base classes. Apart from being a part of an object of A derived class of the abstract base class, you cannot create abstract objects.