Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - In C++, why can’t static constant members of a class be of floating point type?
In C++, why can’t static constant members of a class be of floating point type?

In C++, floating-point and integer static constant members of a class are allowed, but they cannot be initialized in the class. Initialization of static constant members can only be done outside the class definition.

For example:

class

C{

//...

static

const

float

y;

public:

//...

};

const

float

C::y=1.0f;

//Initialization of static constant members

//.. .