#include //妈的,有问题找不出来;
using namespace std;
class point
{
private:
int xpos;
int ypos;
public:
1:point(int x=0,int y=0)
{
cout<<"点的构造函数被执行"<<endl;
xpos=x;
ypos=y;
}
2:point(const point& pt)
{
cout<<"点的复制构造函数被执行"<<endl;
xpos=pt.xpos;
ypos=pt.ypos;
}
3:void print()
{
cout<<"("<<xpos<<","<<ypos<<")"<<endl;
}
};
class line
{
private:
point pt1;
point pt2;
public:
4: line(int x1,int y1,int x2,int y2):pt1(x1,y1),pt2(x2,y2)
{
cout<<"线的构造函数被执行"<<endl;
}
5:line(const line &11):pt1(11.pt1),pt2(11.pt2)
{
cout<<"线的复制构造函数被执行"<<endl;
}
6: void draw()
{
pt1.print();
cout<<" to ";
pt2.print();
cout<<endl;
}
};
int main()
{
7:line 11(1,2,3,4);
8:11.draw();
9:line 12(11);
10:12.draw();
11:return 0;
}
|