偶是初学者,友元怎么实现不了了
这个程序#include <iostream>
using namespace std;
//-------------------
class Point{
int x,y;
public:
Point(int a,int b):x(a),y(b){}
void print()const{cout<<"("<<x<<","<<y<<")\n";}
friend Point operator+(const Point& a,const Point& b);
};
//-------------------------
Point operator+(const Point& a,const Point& b){
Point s(a.x+b.x,a.y+b.y);
return s;
}
//---------------------------
void main(){
Point a(2,3);
Point b(4,7);
(a+b).print();
}
我编译怎么老出错,报错: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
我照书编也有错误,WHY?
难道编译器也有错误?为什么???求救啊