谁来帮我看看啊 急。。
#include<iostream.h>class point
{
private:
int x,y;
public:
point(int a=0,int b=0)
{
x=a;
y=b;
}
point (point &p);
int getx()
{
return x;
}
int gety()
{
return y;
}
};
point ::point(point &p)
{
x=p.x+10;
y=p.y+20;
cout<<"调用拷贝构造函数"<<endl;
}
void f(point p)
{
cout<<p.getx()<<" "<<p.gety()<<endl;
}
point g()
{
point q(3,5);
return q;
}
void main()
{
point p1(2,4);
point p2(p1);
cout<<p2.getx()<<" "<<p2.gety()<<endl;
f(p2); //这里不太懂
cout<<p2.getx()<<" "<<p2.gety()<<endl; //调用完之后X Y为何没变 参数为对象 自动调用拷贝构造函数的。。
p2=g();
cout<<p2.getx()<<" "<<p2.gety()<<endl;
}