new types may not be defined in a return type(c++语言编译错误,处理)

在写程序的时候,定义类时要在大括号后面加上;

class Point{
public:
    Point(int a,int b);
    Point(const Point &p);
    int getx(Point p);
    int gety(Point p);
private:
    int x,y;
}

最后大括号一定要加上分号,上面是错误实例,编译出错

ew types may not be defined in a return type

所以一定别忘了结尾的分号;

class Point{
public:
    Point(int a,int b);
    Point(const Point &p);
    int getx(Point p);
    int gety(Point p);
private:
    int x,y;
};

编译成功。

posted on 2018-03-25 16:06  LeoZhao  阅读(2216)  评论(0编辑  收藏  举报

导航