In this case, it does not matter.
But it can be useful to do.
If you have a large number of participants, then the presence of some, but not all members in the list can cause some confusion. It also strengthens the order of initialization at your disposal (the order is determined by the order of declaration in the class, but it can be useful to visualize this order in larger classes, where not all member variables are declared next to each other).
Note. If you put them in the wrong order in the list of internalizers, this is usually a warning for most compilers (unless you compile with warnings like errors (which you should)).
The real danger is with classes that have POD members and a constructor created by the compiler.
class NewFoo { int x; int y; }; // Version 1: class Bar1 { NewFoo f; }; // Version 2: class Bar2 { NewFoo f; public: Bar2() // f not in list. {} }; // Version 3: class Bar3 { NewFoo f; public: Bar3() : f() {} }; int main() { Bar1 b1a; // x and y not initialized. Bar1 b1b = Bar1(); // x and y zero initialized. Bar2 b2a; // x and y not initialized. Bar2 b2b = Bar2(); // x and y not initialized. Bar3 b3a; // x and y zero initialized. Bar3 b3b = Bar3(); // x and y zero initialized. }
source share