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

編譯成功。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM