All the Syntax problems have indeed helped programmers a lot. However, after the program passes the compilation check, it does not mean that the error does not exist. In the "error" family, the "syntax error" status can only be regarded as a younger brother. High-level errors are often hidden in depth, just like a sly criminal. It is not easy to catch him.
Based on experience, many program errors that are hard to detect are caused by the variable being correctly initialized or cleared, and initialization and cleanup are easily forgotten. Stroustrup fully considers this problem when designing the C ++ language and solves it well: Put the initialization work of the object in the constructor, and put the cleanup work in the destructor. When an object is created, the constructor is automatically executed. When an object dies, the Destructor is automatically executed. You don't have to worry about object initialization and cleanup.
The name of the constructor and the Destructor cannot start at will, and must be recognized by the compiler before it can be automatically executed. The naming method of stroustrup is simple and reasonable: the constructor and destructor have the same name as the class. because the purpose of the constructor is opposite to that of the constructor, the prefix '~ 'To show the difference.
Except for the name, the constructor and the Destructor have no return value type, which is voidDifferent functions. The mission of constructor and destructor is very clear, just like birth and death. If they have return value types, the compiler will be overwhelmed. In order to prevent out-of-the-box branches, it is simply specified that there is no return value type.