标题:[求助]c++基础问题
取消只看楼主
cl_zdl
Rank: 1
等 级:新手上路
威 望:1
帖 子:71
专家分:0
注 册:2006-10-11
 问题点数:0 回复次数:4 
[求助]c++基础问题

请大家看看 错在那?我实在找不到了 ,先谢谢大家了
!#include <iostream>
using namespace std;

class point{
private:
int x,y;
public:
point (int xx,int yy){x=xx;y=yy;}
point (point &p){x=p.x;y=p.y;}

int getx(){return x;}
int gety(){return y;}

};
class rectangle{
private:
point p1,p2;
double area;
public:
rectangle(point xp1,point xp2);
rectangle (rectangle &re);
double getarea(){return area;}
}
rectangle::rectangle(point xp1,point xp2):p1(xp1),p2(xp2)
{ cout<<"gou zhao han shu bei diao yong:"<<endl;
double len1=double(p1.getx()-p2.getx());
double len2=double(p1.gety()-p2.gety());
area=len1*len2;
}
rectangle::rectangle(rectangle &re):p1(re.p1),p2(re.p2)
{cout<<"kao bei gou zao han shu bei diaoyong "<<endl;
area=re.area;
}
void main()
{point myp1(1,2),myp2(4,6);
rectangle A(myp1,myp2);
cout<<"area is ";
cout<<A.getarea;
}
错误调试:
-------------------Configuration: 11 - Win32 Debug--------------------
Compiling...
11.cpp
D:\11\11.cpp(24) : error C2533: 'rectangle::rectangle' : constructors not allowed a return type
D:\11\11.cpp(36) : error C2264: 'rectangle::rectangle' : error in function definition or declaration; function not called
Ö´ÐÐ cl.exe ʱ³ö´í.

11.obj - 1 error(s), 0 warning(s)

搜索更多相关主题的帖子: 基础 
2006-10-29 10:03
cl_zdl
Rank: 1
等 级:新手上路
威 望:1
帖 子:71
专家分:0
注 册:2006-10-11
得分:0 
感叹号和上边是一体的。
2006-10-29 10:04
cl_zdl
Rank: 1
等 级:新手上路
威 望:1
帖 子:71
专家分:0
注 册:2006-10-11
得分:0 

不行啊 ,还是老错误!

2006-10-29 11:04
cl_zdl
Rank: 1
等 级:新手上路
威 望:1
帖 子:71
专家分:0
注 册:2006-10-11
得分:0 
那不是主要错误啊!
2006-10-29 11:04
cl_zdl
Rank: 1
等 级:新手上路
威 望:1
帖 子:71
专家分:0
注 册:2006-10-11
得分:0 

谢谢大家的帮忙!

2006-10-31 07:35



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




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

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