1.赋值不必定是初始化。例如函数
AClassName::AClassName(const std::string &name, const std::string &address, const std::list<PhoneNumber> &phones) { theName = name; //这些都是赋值 theAddress = address; //而非初始化 thePhones = phones; numTimesConsulted = 0; } AClassName::AClassName(const std::string &name, const std::string &address, const std::list<PhoneNumber> &phones) :theName(name), //这些都是初始化 theAddress(address), thePhones(phones), numTimesConsulted(0) {} //构造函数本体没必要作任何动做
2.类的默认继承级别为private,而struct默认为public。spa
PS:①public继承,基类成员保有本身的访问级别:基类的public为派生类的public,基类的protected为派生类的protected;②protected继承,基类的public和protected在派生类中为protected;code
③private继承,基类全部成员在派生类中为private。blog