您好我在尝试编译代码时遇到以下错误。 错误C2143:语法错误:缺少';'在'。'之前当我打电话
Points.addPoints(); 谢谢你的帮助。
#ifndef _POINTS_H
#define _POINTS_H
//points.h
#include <sstream>
using namespace std;
class Points{
int pointsADD;
int pointsRemove;
int newPoints;
public :
Points(int points){this->pointsADD=points;this->pointsRemove=pointsRemove;this->newPoints=newPoints;}
void addPoints(int newPointsADD){
newPoints=pointsADD+newPointsADD++;
}
void removePoints(int newPointsRemove){
newPoints=pointsRemove+newPointsRemove--;
}
int getPoints(){
return newPoints;
}
};
#endif
答案 0 :(得分:3)
您需要该类的实例来添加任何内容。阅读一篇优秀的C ++简介,并立即修复:
Points p(42);
p.addPoints(23);