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;
};

编译成功。

原文地址:https://www.cnblogs.com/BlogOfMr-Leo/p/8645132.html