Preferred way of class member initialization?
问题 class A { public: int x[100]; }; Declaring A a will not initialize the object (to be seen by garbage values in the field x ). The following will trigger initialization: A a{} or auto a = A() or auto a = A{} . Should any particular one of the three be preferred? Next, let us make it a member of another class: class B { public: A a; }; The default constructor of B appears to take care of initialization of a . However, if using a custom constructor, I have to take care of it. The following two