加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 为什么不编译?

发布时间:2020-12-16 10:45:32 所属栏目:百科 来源:网络整理
导读:我在这里创建了这个课: //整数矩形类 class AguiRectangle { int x; int y; int width; int height;public: bool isEmpty { return x == 0 y == 0 width == 0 height == 0; } int getTop() { return x; } int getLeft() { return y; } int getBottom() { re
我在这里创建了这个课:

//整数矩形类

class AguiRectangle {
    int x;
    int y;
    int width;
    int height;
public:

    bool isEmpty {

        return x == 0 && y == 0 &&
           width == 0 && height == 0;
    }

    int getTop() {
        return x;
    }
    int getLeft() {
        return y;
    }

    int getBottom() {
        return y + height;
    }
    int getRight() {
        return x + width;
    }

    AguiPoint getTopLeft()
    {
        return AguiPoint(getTop(),getLeft());
    }
    AguiPoint getBottomRight()
    {
        return AguiPoint(this->getBottom(),this->getRight());
    }
};

编译器告诉我x和y以及宽度和高度是未声明的.这几乎就像班级没有看到自己.

谢谢

Error   14  error C2673: 'getBottomRight' : global functions do not have 'this' pointers    c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   178
Error   16  error C2673: 'getBottomRight' : global functions do not have 'this' pointers    c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   178
Error   13  error C2665: 'AguiPoint::AguiPoint' : none of the 4 overloads could convert all the argument types  c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   174
Error   6   error C2628: 'AguiRectangle' followed by 'int' is illegal (did you forget a ';'?)   c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   158
Error   3   error C2473: 'isEmpty' : looks like a function definition,but there is no parameter list.  c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   153
Error   5   error C2238: unexpected token(s) preceding ';'  c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   156
Error   17  error C2227: left of '->getRight' must point to class/struct/union/generic type c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   178
Error   15  error C2227: left of '->getBottom' must point to class/struct/union/generic type    c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   178
Error   2   error C2146: syntax error : missing ';' before identifier 'result'  c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   64
Error   19  error C2143: syntax error : missing ';' before '}'  c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   180
Error   21  error C2079: 'pp' uses undefined class 'AguiPointf' c:UsersJoshDocumentsVisual Studio 2008ProjectsAguiAlleg_5main.cpp   35
Error   8   error C2065: 'y' : undeclared identifier    c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   162
Error   9   error C2065: 'y' : undeclared identifier    c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   166
Error   7   error C2065: 'x' : undeclared identifier    c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   159
Error   11  error C2065: 'x' : undeclared identifier    c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   169
Error   12  error C2065: 'width' : undeclared identifier    c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   169
Error   10  error C2065: 'height' : undeclared identifier   c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   166
Error   4   error C2059: syntax error : 'return'    c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   155
Error   18  error C2059: syntax error : '}' c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   180
Error   20  error C2059: syntax error : '}' c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   180
Error   1   error C2027: use of undefined type 'AguiPointf' c:usersjoshdocumentsvisual studio 2008projectsaguialleg_5AguiAguiBaseTypes.h   59

解决方法

应该

bool isEmpty()

代替

bool isEmpty

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读