Nothing magic here. One is permitted syntax one isn't. For const member variables must be declared in class and defined outside.
http://www-01.ibm.com/support/knowledgecenter/SSLTBW_1.12.0/com.ibm.zos.r12.cbclx01/cplr038.htm[
^]
So:
class foo
{
public :
static const float f;
};
const float foo:f = 5.0f;
in c++11 you could do:
class foo
{
public :
static constexpr float f = 5.0f;
};
However some C++ compilers allow the omission of an external definition for int but it is advised to have one if you intend taking the address later. This is because the compiler may remove the variable and just keep the value.
See here:
http://stackoverflow.com/questions/1312241/using-a-static-const-int-in-a-struct-class[
^]
This is what you discovered. You did not mention your compiler but that is crucial here.
For further explanation look here:
http://stackoverflow.com/questions/11300652/static-data-member-initialization[
^]
Quote
"On the other hand, a static member variable is not contained within an instance of the class, it exists independently of any single instance and exists from the start of the program, at a fixed address. In order for a static member variable (or any other global object) to get a unique address the linker must see exactly one definition of the static variable, in exactly one object file, and assign it an address.
Because a static variable needs exactly one definition in exactly one object file, it doesn't make sense to allow that definition to be provided in the class, since class definitions typically exist in header files and are included in multiple object files. So although you can provide an initializer in the class, you still need to define the static data member somewhere"
Enums do not exist in memory they are entirely handled by the compiler:
http://stackoverflow.com/questions/1206579/memory-location-of-enum-value-in-c[
^]