? questions raised
is mainly in the VC + + 2015 often hints of inexplicable compilation errors.
To analyze why the constructor in Java is a simple question:
1. The object types in C + + are not only passed by reference, but may also be copied for delivery. So sometimes you have to provide a copy constructor . (This is the same as the overloaded assignment operator = seemingly purpose?) To be able to construct a 2nd instance based on 1 instance)
If you do not explicitly customize a copy constructor, the compiler provides a "shallow copy" by default. Therefore: When a member variable contains a pointer type for an object, the copy constructor must be overridden. --rewriting is almost inevitable?
2. There are 2 things in C + + that have an initial value and a list of initialization .
3. The constructor and copy constructor provided by default can also be deleted by the "= delete" function. I don't know what the situation is. ( slot: C + + Adds a lot of detail to the grammar with syntactic sugar, making the syntax quite miscellaneous, motherfucker )
4. Although there is only one C + + specification, the compiler that implements the specification has several products: MSVC, g++, Clang ... And they each have a bunch of versions, support for C + + standards, additions are different, not to mention there are still some static code check the rules are not the same, give the message I often do not understand ... Can only take Google and then face a lot of grammatical details, want to die ...
? "Default Initialization"
1. If a constructor is not explicitly provided, the compiler provides a default parameterless constructor ("default constructor").
"C + + Primer":
Or Baidu know understood Point:--> Design Section test code, debug look to know.
? The answer is here
Auto-Initialization of C + + variables
W3 Sunday __c++ There are too many subtle to egg-ache details. Like a constructor that can make so many moths.