写完这个程序后,按F7不顶用!!!怎么办???跪求答案!
#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 getlengh() {return len;}
private:
point p1, p2;
};
line::line(point xp1, point xp2) : p1(xp1),p2(xp2)
{
cout<<"line构造函数被调用"<<endl;
double x = double(p1.getX() - p2.getY());
double y = double(p1.getX() - p2.getY());
len = squrt(x*x + y*y);
}
line::line(line & l):p1(l.p1) , p2(l.p2)
{
cout<<"line拷贝构造函数调用"<<endl;
len = l.getlengh;
}
int main()
{
point myp1(1,1), myp2(4,5);
line line(myp1, myp2);
line line2(line);
cout<<"the length of the line is:";
cout<<line.getlengh<<endl;
cout<<"the lengh of the line2 is:";
cout<<line2.getlengh()<<endl;