哪位高手帮我看下这个C++程序哪里出错了,是重载运算符的

[复制链接]
查看11 | 回复1 | 2010-5-28 01:32:45 | 显示全部楼层 |阅读模式
#include
#include
class point
{
double x,y;
public:
point (double x0=0, double y0=0)
{x=x0; y=y0;}
point operator + (point pt2);
double operator ^ (point pt2);
void display();
};
point::point(double x0,double y0)
{
x=x0;
y=y0;
}
point point::operator +(point pt2)
{
point p;
p.x=x+pt2.x;
p.y=y+pt2.y;
return p;
}
point point::operator ^(point pt2)
{
point p;
p.x=(x-pt2.x)*(x-pt2.x);
p.y=(y-pt2.y)*(y-pt2.y);
return sqrt(x+y);
}
void point::display()
{
cout//using namespace std;//class point { double x,y;public: point (double x0=0, double y0=0)//函数“point::point(double,double)”已有主体,所以删了下面一段 {x=x0; y=y0; }point operator + (point pt2); double operator ^ (point pt2); void display();};point point::operat
回复

使用道具 举报

千问 | 2010-5-28 01:32:45 | 显示全部楼层
世界上最烂的程序...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行