Preface: While I start implementing the constructor of a class, at the point I typed "Foo::Foo() : " I use to write the initialization list with all superclass constructors and all member variables.
Topic: There should be a suggestion to automatically create the whole initialization list. When I select this suggestion which could be called "Create initialization list" I get e.g. this result:
Header:
class Bar {};
class Foo {
public:
Foo( int apple, int banana );
private:
int m_apple;
int m_banana;
double m_cinnamon;
};
I start at this point (| = cursor):
Foo::Foo( int apple, int banana )
: |
The suggestion box appears and I select "Create initialization list". Now I have this situation:
Foo::Foo( int apple, int banana )
: Bar(), m_apple( apple ), m_banana( banana ), m_cinnamon( 0.0 /* TODO: */ )
{
|
}
Your objections: - Not every initialization is necessary. (I think: you can remove the not necessary member initializations afterwards)
- Providing a default value while initializing the members is dangerous. (I think: That's true, instead only a comment or other placeholder could written at such places.)