I have read that it is highly recommend that all data members, regardless of type, are initialized when a class is created and that the initializer list of the constructor is the best place to do this.
What about data members that are objects? Assuming that object has a default initializer that suffices, is it considered good practice to omit them from the initializer?
Such as:
class A{
private:
AnotherClass B;
int x;
public:
A():x(5){} //B is never explicitly initialized
};
If you don’t use member initializer list for initializing members which are of user defined type the default constructor of that particular type will be called to initialize the member object.
So as long as your members have default constructors available and that is your intent, it is perfectly fine.
It is a matter of choice and preference. For me member initializer lists are more intuitive so i prefer them.