7.5.3. The Role of the Default Constructor
The default constructor is used automatically whenever an object is default or value initialized. Default initialization happens
• When we define nonstatic
variables (§ 2.2.1, p. 43) or arrays (§3.5.1, p. 114) at block scope without initializers
• When a class that itself has members of class type uses the synthesized default constructor (§ 7.1.4, p. 262)
• When members of class type are not explicitly initialized in a constructor initializer list (§ 7.1.4, p. 265)
Value initialization happens
• During array initialization when we provide fewer initializers than the size of the array (§ 3.5.1, p. 114 ...
Get C++ Primer, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.