Saturday, 28 September 2013

Why double is not allowed in in-class intializer

Why double is not allowed in in-class intializer

I have been reading Exceptional C++ by Herb Shutter Item 1 : #define or
const and inlining..
Its said that the in-class initialization is allowed only for integral
types(integers,chars,bools) and only for constants..
I just want to know why double/float cannot be initialized in class
declaration .. Are there any specific reasons.
class EngineeringConstants { // this goes in the class
private: // header file
static const double FUDGE_FACTOR;
...
};
// this goes in the class implementation file
const double EngineeringConstants::FUDGE_FACTOR = 1.35;
I just want to know the reason why the below declaration is not allowed.:,,
class EngineeringConstants { // this goes in the class
private: // header file
static const double FUDGE_FACTOR = 1.35;
...
};

No comments:

Post a Comment