在点函数上出现以下错误

发布于 2024-12-19 20:37:47 字数 642 浏览 0 评论 0原文

您好,当我尝试编译代码时出现以下错误。 错误 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

Hi I am getting the following error when i am trying to compile my code.
error C2143: syntax error : missing ';' before '.' when i call

Points.addPoints();
Thanks for any help.

#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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葵雨 2024-12-26 20:37:47

您需要类的实例才能添加任何内容。阅读一篇很好的 C++ 介绍,并立即修复:

Points p(42);
p.addPoints(23);

You need an instance of the class to add anything. Read a good C++ introduction, and fix for now:

Points p(42);
p.addPoints(23);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文