#include <iostream>
#include <stdlib.h>
using namespace std;
class Point
{
public:
Point(int xx =0,int yy =0)
{
X=xx;
Y=yy;
}
Point(Point &p);
int GetX()
{
return X;
}
int GetY()
{
return Y;
}
private:
int X,Y;
};
Point::Point(Point &p)
{
X=p.X;
Y=p.Y;
cout<<"拷贝构造函数被调用"<<endl;
}
void fun1(Point p)
{
cout<<p.GetX()<<endl;
}
Point fun2()
{
Point A(1,2);
return A;
}
int main()
{
Point A(4,5);
Point B(A);
cout<<B.GetX()<<endl;
fun1(B);
B=fun2();
cout<<B.GetX()<<endl;
system("pause >nul");
}
在编译时为什么会出现:no matching function for call to `Point::Point(Point)'
的错误?