| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 714 人关注过本帖
标题:写完这个程序后,按F7不顶用!!!怎么办???跪求答案!
只看楼主 加入收藏
sadan
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-8-11
收藏
 问题点数:0 回复次数:1 
写完这个程序后,按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
elegant87
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2008-1-15
收藏
得分:0 
语法错误太多了
#include<iostream>
#include<cmath>

using namespace std;

class point
{
public:
    point(int xx = 0, int yy = 0 ) {X=xx , Y = yy;}
    point(const point &p);
    int getX() {return X;}
    int getY() {return Y;}
private:
    int X , Y;

};

point::point(const point &p)
{
   X = p.X;
   Y = p.Y;
   cout<<"point ..........."<<endl;
}

class line
{
public:
    line();
    line(point xp1, point xp2);
    line(const line &);
    double getlengh() const  {return len;}
private:
    point p1, p2;
    double len;

};
line::line()
{
   cout<<"默认构造函数被调用!"<<endl;
}
     
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 = sqrt(x*x + y*y);
}
line::line(const line &l):p1(l.p1),p2(l.p2)
{
    cout<<"line拷贝构造函数调用"<<endl;
    len = l.getlengh();
}
int main()
{
    point myp1(1,1), myp2(4,5);
    line line1(myp1, myp2);
    line line2=line1;//调用拷贝构造函数
    cout<<"the length of the line is:";
    cout<<line1.getlengh()<<endl;
    cout<<"the lengh of the line2 is:";
    cout<<line2.getlengh()<<endl;
    system("pause");
    return 0;
}

你的语法错误太多了呀!以后注意!
2008-08-11 16:59
快速回复:写完这个程序后,按F7不顶用!!!怎么办???跪求答案!
数据加载中...
 
   



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

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