When is empty class no longer a null? When C + + has processed it, yes, if you don't declare it yourself, the compiler will declare it (compiler Version) a copy constructor, a copy assignment operator, and a destructor. In addition, if you do not declare any constructors, the compiler will also declare a default constructor for you. All of these are public and inline.
The copy assignment operator generated by the compiler behaves essentially like the copy constructor, but is generally only generated if the resulting code is legitimate and has the appropriate opportunity to prove it makes sense.
If a reference data member and a const member exist in the class, copy assignment is not generated at this time. Because C + + does not allow "to change a reference to a different object".
In the face of such a problem, C + + response is to refuse to compile the line assignment action. If you intend to support assignment operations within a class that contains reference members, you must define the copy assignment operator yourself. The compiler reacts the same way to the classes, which contains the const member. Changing a const member is not legal, so the compiler does not know how to confront it within its own generated assignment function. Finally, there is the case that if a base class declares the copy assignment operator as private, the compiler will refuse to generate a copy assignment operator for its derived class. After all, the copy assignment operator that the compiler has built for derived classes can handle the base class component, but of course they cannot invoke the member functions that derived class does not have permission to invoke. The compiler can do nothing with his hands.
What functions the C + + compiler silently writes and calls