声明类函数operator+时,编译出错
程序全文如下,编译时出错的行已经改成红色,错误描述为:fatal error C1001: INTERNAL COMPILER ERROR(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
这是怎么回事儿啊???
ps:编译器是VC6.0
#include <iostream>
using namespace std;
class Point
{
int x,y;
public:
void set(int a,int b)
{
x=a,y=b;
}
void print()const
{
cout<<'('<<x<<','<<y<<')\n';
}
friend Point operator +(const Point& a,const Point& b);
friend Point add(const Point& a,const Point& b);
}
Point operator+(const Point& a,const Point& b)
{
Point s;
s.set(a.x+b.x,a.y+b.y);
return s;
}
Point add(const Point& a,const Point& b)
{
Point s;
s.set(a.x+b.x,a.y+b.y);
return s;
}
void main()
{
Point a,b;
a.set(3,2);
b.set(1,5);
(a+b).print();
operator+(a,b).print();
add(a+b).print();
}
[此贴子已经被作者于2007-3-29 21:14:13编辑过]