Object slicing is the forced conversion of the value class. Example:
Class cDocument is the base class of CMYDOT,
CDocument * PDOT;
CMYDOT * PMYDOT = New CMYDOT;
PDOT = (cDocument *) PMYDOT; this is normal to achieve multiple transformations. But if the pointer is changed to a value:
CMYDOT PMYDOT;
(Cdocument) PMYDOT.FUCTION (); will have problems, the compiler generates a CDoucment class object and assigns the value to PMYDOT, so that the original object is cut, and the virtual function pointer and table are also assigned, Unable to dynamically, PMYDOT has become CDocument objects. That's why you must use a pointer to realize dynamic truth.
The Static member variable is not part of the object, but part of the category, so the program can handle this member variable when any object has not been born. But first you have to initialize it.
Do not arrange the initialization action of Static member variables in the category of category, because the construction of the construction may be called again and again, and the initial value of the variable should only be set once. Do not arrange the initialization action in the header, because it may be included in many places, so you may be executed many times. You should set its initial value anywhere in the implementation and categories. For example, in main, or in a regional function, or any functions: