在这段代码中,我不知道编译器为什么不让我将值0赋值给变量x。我突出了导致问题的线。给静态变量赋值时出错
class List{
private:
int p;
public:
static int x;
void total();
};
void List::total(List *a){
x + = a -> p;
cout<<x;
getch();
x=0; // problem here
}
我也注意到,如果我在函数体前写INT表::总和= 0,程序工作得很好。我只是不明白为什么。 我感谢任何帮助!
_你有什么错误? – SLaks