[Chapter] c ++ study notes 3 (constructor)

One member of the function
(1) name the same as the class name, the parameters can not have a return value (void nor)
(2) function is to initialize an object, such as a member variable to the initial value
(3) if the class definition of I did not write a constructor, the compiler generates a default constructor with no arguments (the default constructor with no arguments, do nothing)
(4) If the definition of a constructor, the compiler does not generate a default no-argument constructor
(5) constructor called when the object is automatically generated. Once the object generation, they can not be performed thereon constructor
(6) may be a class has multiple constructors
effect constructor

use example




used in the array constructor


Guess you like

Origin www.cnblogs.com/lamia76/p/12301832.html