I have this question bugging me.
Why cant I have code like this in my .hpp
file.
class H {
private:
static const int i =5;
static const float f = 1.0;
static const string s = "string";
}
Only int, bool, enum and constexpr etc can be declared and initialized like that.
My questions:
-
Why do strings and other complex datatypes needs proper initialization in cpp? They are constant.
-
Why do we have different behavior for floats and ints? my guess:gcc does not support that, but can be supported easily if we use constexpr.
Aucun commentaire:
Enregistrer un commentaire