Reputation: 4354
I have some issues in compiling a code. I have this particular code
typedef double Type;
static const Type MAX_VALUE = __DBL_MAX__;
static const Type MIN_VALUE = -__DBL_MAX__;
Now when I try to compile it. It shows the following error
error: a call to a constructor cannot appear in a constant-expression
I change the definition const to constexpr. But it shows the following error
error: ‘constexpr’ does not name a type
note: C++0x ‘constexpr’ only available with -std=c++0x or -std=gnu++0x
How can I fix this issue?
Upvotes: 0
Views: 1992
Reputation: 283634
My crystal ball tells me these lines are inside a class definition. That's a very important piece of information you left out.
Prior to C++11, only integral and enumerated static members could be initialized inside the class body. Others, including floating-point, must be defined outside.
Upvotes: 1