This is what I have now:
class CColorf
{
public:
CColorf();
CColorf(float r, float g, float b, float a = 1.0f);
public:
float r, g, b, a;
// predefined colors
// rgb(0.0, 0.0, 1.0)
static const CColorf blue;
};
It works with blue defined in ccolorf.cpp like so:
CColorf const CColorf::blue = CColorf(0.0f, 0.0f, 1.0f);
And this is what I would like to do:
class CColorf
{
...
// predefined colors
// rgb(0.0, 0.0, 1.0)
static const CColorf blue = CColorf(0.0f, 0.0f, 1.0f);
};
But it produces a compilation error:
a static data member with an in-class initializer must have non-volatile const integral type
Is there a way to avoid the need for separate declaration and definition here?
Aucun commentaire:
Enregistrer un commentaire