In a Code::Blocks v13.12
project I have a class called Drawable
which has a floating point member variable called rotation
.
I noticed that explicitly declaring rotation
inside Drawable
's default constructor would trigger the following warning:
'Drawable::rotation' should be initialized in the member initialization list [-Weffc++]
However, explicitly declaring rotation
alongside its definition doesn't do this.
What I want to know is, why does this:
Drawable() {
rotation = 0.f;
}
Give me a member initialization warning, while this:
class Drawable
{
...
float rotation = 0.f;
...
}
And this:
Drawable() : rotation(0.f) {}
Compile without complaint?