In the code base I'm working with there's dozens of header initalized variables:
bool toBeTrue = true;
int var = 1;
And if they're not initialized in the header file they're initialized in the constructor's body:
MyClass::MyClass()
{
variable1 = 10;
boolean2 = false;
};
Does initializing the variables in the header file (maybe having pointers initialzed to nullptr
, booleans
and simple ints
in the header file makes sense?) make the compilation time slower? And would moving all the variable initialization moved to the constructor's initialization list make the compilation time faster?