List initial: Use curly braces to do a preliminary
Direct initial: Put parameters in parentheses to preliminary
Copy initial: Use = or the tired object as an initial parameter
Value initiation: The space opened in C + + enables value initialization by the type name of the space being initialized, followed by (), and the library type automatically enables value initialization for uninitialized variables.
1. When the variable is a built-in type, the value initialization is initialized with zero.
2. When the variable is a class type, the value initialization is initialized with the default constructor of the class.
3. When a variable is of class type and there is no default constructor, the initialization of the value requires the programmer to provide the initialization value.
By default, dynamically allocated objects are initialized by default, which means that the value of an object of a built-in type or combination of types is undefined, whereas a class-type object Initializes a default constructor, or a value is initialized on a dynamically allocated object, just a pair of empty parentheses followed by a type name.
In the default constructor of the composition , if it is a class object, the default constructor for the object is called, and if it is a built-in type, it is undefined.
#include <iostream>using namespacestd;classa{ Public:Private: A&operator=(Consta&); intA;};intMainintargcChar**argv) {A A,*PA =NewA (); return 0;}
a={a=-6589} // did not give a preliminary *pa={a=0} // built-in type 0
Direct initial examination, copy initial, value preliminary