To sum up
For example
C1 * P = new C2 ();
Delete P;
Such code
Here, C1 is the base class of C2. C1 may be the father of C2, grandpa, or Grandpa of C2, it may be grandpa's grandfather ..............................
First, the called constructor is
From the first ancestor of C2 to C2 ................... It's okay with C1.
When deleting P, there are the following situations:
1) if the ancestor (base class) of C1 or C1 contains a virtual destructor, the sequence of the called destructor is the first ancestor from C2 to C2.
2) If none of the ancestor C1 or C1 contains a virtual destructor, it calls the First Ancestor from C1 to C1 (which is also C2 ).
3) If C1 is void, no destructor will be called.
If a class is a base class of polymorphism, declare the Destructor as virtual. Otherwise ..................,
After confirmation by VC ++, we firmly believe that the token is correct.