VC++6 error C2059: syntax error : 'constant'
问题 Made this simple class with MSVC++ 6.0 class Strg { public: Strg(int max); private: int _max; }; Strg::Strg(int max) { _max=max; } Sounds good if I use it in : main() { Strg mvar(10); } But Now If I use it in an another class : class ok { public: Strg v(45); }; I get message error : error C2059: syntax error : 'constant' Could you tell me more please ? 回答1: Should be: class ok { public: Strg v; ok() : v(45) {} }; Non-static member variables that don't have default constructors (v in this case