The problem with the following code is static member of type "const double" cannot have an in-class initializer. Why is applicable only for a \'const double\'in th
The compiler offered me to use constexpr instead of const:
static_consts.cpp:3:29: error: ‘constexpr’ needed for in-class initialization of static data member ‘const double sample::md’ of non-integral type [-fpermissive]
static_consts.cpp:7:22: error: ‘constexpr’ needed for in-class initialization of static data member ‘const double sample::md’ of non-integral type [-fpermissive]
I've just accepted the offer:
class sample{
   static const char mc = '?';
   static constexpr double md = 2.2;
   static const bool mb = true;
};
const char sample::mc;
const bool sample::mb;
int main(){
}
And now it compiles just fine (C++11).