哪位高手给我解析一下
#include <iostream>
#include <cmath>
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 <<"point拷贝构造函数被调用;"<<endl;
}
class Line
{
public:
Line(Point xp1,Point xp2); //不懂
Line(Line &); //不懂
double GetLen() {return len;}
private:
Point p1,p2; //不懂
double len;
};
Line::Line(Point xp1,Point xp2)
:p1(xp1),p2(xp2) //不懂
{
cout <<"Line的构造函数被调用"<<endl;
double x=double(p1.GetX()-p2.GetX());
double y=double(p1.GetX()-p2.GetY());
len=sqrt(x*x+y*y);
}
Line::Line(Line &L):p1(L.p1),p2(L.p2) //不懂
{
cout<<"Line拷贝构造函数被调用"<<endl;
len=L.len;
}
void main()
{
Point myp1(1,1),myp2(4,5);
Line line(myp1,myp2);
Line line2(line);
cout<<"第一条线的长度是:";
cout<<line.GetLen()<<endl;
cout<<"第二条线的长度是:";
cout<<line2.GetLen()<<endl;
}