请大家看看 错在那?我实在找不到了 ,先谢谢大家了
!#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)