I am learning about classes, and chapter 7.1.4 of the book C++ Primer says the following:
The compiler-generated constructor is known as the synthesized default constructor. For most classes, this synthesized constructor initializes each data member of the class as follows:
- If there is an in-class initializer (§ 2.6.1, p. 73), use it to initialize the member.
- Otherwise, default-initialize (§ 2.2.1, p. 43) the member.
If the class members already have an in-class initializer, why would this synthesized default constructor initialize them again? Also, I thought that initialization is a thing that can only happen once. The above suggest that the members are initialized twice, once explicitly, and once implicitly by the synthesized default constructor.