Questions tagged «members»

5
静态类成员上未解析的外部符号
简单地说: 我有一个主要由静态公共成员组成的类,因此我可以将仍然必须从其他类/函数调用的相似函数组合在一起。 无论如何,我在类的公共范围内定义了两个静态的无符号char变量,当我尝试在同一类的构造函数中修改这些值时,在编译时出现“无法解析的外部符号”错误。 class test { public: static unsigned char X; static unsigned char Y; ... test(); }; test::test() { X = 1; Y = 2; } 我是C ++的新手,所以轻松一点。我为什么不能这样做?
129 c++  class  static  members 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.