Summary of constructor initializes member list in C++

  • 2020-05-10 18:34:17
  • OfStack

1. The type of a member variable that can only be initialized in the constructor initialization list ?

    a.const member variable

    b. Member variable of the reference type

    c.static cannot be initialized in the initialization list

    d. Variables with a custom type in the class member variables are best initialized in the initialization list

2. The order of initializing the list ?

The initialization order of the     initialization list is based on the order in which the class member variables are defined.

3. Whether static const should be initialized in the initialization member list ?

    static const is a global static constant, which means that the variable belongs to the class as a whole and is not an instance of a class, so it cannot be initialized in the initialization list.


Related articles: