Use Constructor Initializers

C++ Primer 4/e在Constructors这个地方有一个忠告:‘In many classes, the distinction between initialization and assignment is strictly a matter of low-level efficiency: A data member is initialized and assigned when it could have been initialized directly. More important than the efficiency issue is the fact that some data members must be initialized.

We must use an initializer for any const or reference member or for any member of a class type that does not have a default constructor.

By routinely using constructor initializers, we can avoid being surprised by compile-time errors when we have a class with a member that requires a constructor initializer.’




没有这个习惯,唉! 🙁