Why aren't static const floats allowed?
- by Jon Cage
I have a class which is essentially just holds a bunch of constant definitions used through my application. For some reason though, longs compile but floats do not:
class MY_CONSTS
{
public :
static const long LONG_CONST = 1; // Compiles
static const float FLOAT_CONST = 0.001f; // C2864
};
Gives the following error:
1>c:\projects\myproject\Constant_definitions.h(71) : error C2864: 'MY_CONSTS::FLOAT_CONST' : only static const integral data members can be initialized within a class
Am I missing something?