As we learned in Section 2.8 (p. 65), class data members are not initialized when the class is defined. Instead, data members are initialized through a constructor.
正如在第2 . 8节所学习的,在定义类时没有初始化它的数据成员,而是通过构造函数来初始化其数据成员。
There is one crucially important difference between how we define variables and class data members: We ordinarily cannot initialize the members of a class as part of their definition.
定义变量和定义数据成员存在非常重要的区别:一般不能把类成员的初始化作为其定义的一部分。
It includes all class data members, all class member functions (either explicitly declared, or implicitly generated by the compiler), all base classes of the class, and all their members. Consider.
它包括所有类的数据成员,所有类的成员函数(或者显式声明,或者由编译器隐式生成),所有类的基类和所有它们的成员。
应用推荐