The difference between a bit copy (a shallow copy) and a value copy (deep copy) should be made clear first (reference http://blog.sina.com.cn/s/blog_a2aa00d70101gpvj.html). A bit copy, and "bitwise copy" means to copy the memory image of an object to another object, simply by bit; A value copy means to copy the value of the original object to a new object. When you use "bitwise Assignment", the object's memory image is copied directly to another object, so that two objects point to the same memory area, and when one object is freed, the other object's pointer becomes a null pointer.
In general, a good compiler can generate bitwise copies for most class object, but when you do not have to "bitwise copies", the compiler produces the default constructor and copy constructor, and the following four cases do not require " Bitwise copies "(Consistent with the previous subsection, just replace the default constructor with a copy constructor):
1 if a class does not have a copy constructor, but contains a member variable of a class type that contains a copy constructor, the compiler will then synthesize a copy constructor for the class;
2 If a class does not have a copy constructor, but the class inherits from the base class containing the copy constructor, the compiler then synthesizes a copy constructor for the class;
3 If a class does not have a copy constructor, but the class declares or inherits the virtual function, the compiler will then synthesize a copy constructor for the class;
4 If a class does not have a copy constructor, but the class contains a virtual base class, the compiler will then synthesize a copy constructor for the class;
The third situation explains the second issue of the first chapter, "on objects", because it is not in the semantic context of "bitwise copies" At this time, the compiler generates a copy constructor in which the virtual function pointer still points to the virtual function table address of the class, such as (reference):
Automatically generates a copy constructor for Class A, vptr the Class A object in the function, roughly as follows:
A::A (const a& A)
{
The virtual function table address of the This->vptr=a class;
}