I’m sure there is ugly thing everyone time to time faces with.
The problem is adding one more field to a class and forgetting expand initialisation list e.g.:
class T{
private:
field1;
...
field10;
};
T::T( int speedValue ):
field1( Speed::MphToMps(speedValue) ),
field2( new OtherClass(14,5,15) ),
field3( PublicValueGenerator::generateNewFieldValue(0,15) ),
...,
field10( "unpredictable value" );
And if in hurry I add some field, say newForgottenField, time to time I forget to set init value.
As I remeber some IDEs can give a hint, but vim+addons is my choice 🙂
So mb there is some hint for simplifying tracking such situations or some rule of thumb or rude macros which gives warning or compile-time error(that would be amazing:))?
How do you overcome that obstacle?
Best regards
If you are using g++ then it provides an option which enables warnings for constructs that violate guidelines in Scott Meyer’s Effective C++ 🙂
The option is:
Do note that it will also enable a number of other warnings as well.Also, not all of the standard library headers follow Meyers guildelines.