标题:写完这个程序后,按F7不顶用!!!怎么办???跪求答案!
取消只看楼主
sadan
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-8-11
 问题点数:0 回复次数:0 
写完这个程序后,按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;
搜索更多相关主题的帖子: point line 顶用 return 
2008-08-11 01:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-227632-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.283816 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved