Warum nicht static const Schwimmern erlaubt?

Habe ich eine Klasse, die ist im Grunde nur enthält eine Reihe von Konstanten-Definitionen verwendet, die durch meine Anwendung. Aus irgendeinem Grund obwohl, longs kompilieren aber floats nicht:

class MY_CONSTS
{
public :
    static const long   LONG_CONST = 1;      //Compiles 
    static const float FLOAT_CONST = 0.001f; //C2864
};

Gibt die folgende Fehlermeldung:

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

Bin ich etwas fehlt?

InformationsquelleAutor Jon Cage | 2010-03-16

Schreibe einen Kommentar