求助编译出错怎么回事??坐等
程序:程序代码:
#include <iostream> using namespace std; class Point { public: Point(int xx=0, int yy=0) {X=xx; Y=yy; cout<<"The construct fun called"<<endl;} Point(Point& p); // Point(Point p); int GetX() {return X;} int GetY() {return Y;} // Point& test(Point& a); private: int X, Y; }; Point::Point(Point& p) { X=p.X; Y=p.Y; cout<<"The copy construct fun called 11111"<<endl; } /* Point::Point(Point p) { X=p.X; Y=p.Y; cout<<"The copy construct fun called 22222"<<endl; } */ Point test(Point a) { cout<<"test"<<endl; return a; } int main(int argc , char** argv) { Point box1(2, 2); cout<<"first"<<endl; Point box2=box1; cout<<"second"<<endl; Point box3(box1); cout<<"third"<<endl; Point box4; cout<<"forth"<<endl; box4=box1; cout<<"fifth"<<endl; test(box3); box2=test(box3);//出错! Point box5=test(box3);//出错! return 0; }