#include <iostream>
using namespace std;
class PPoint
{
public:
void set(int a,int b){x=a;y=b;};
   friend PPoint operator+( int first, PPoint &second );
private:
   float x, y;
};PPoint operator+( int first, PPoint &second )
{
PPoint ss;
ss.set(first+second.x,second.y);
return ss;
}
void main()
{}

解决方案 »

  1.   

    奇,总要说一下问题是什么原因,你要是在VC6.0下就把头文件改成#include <iostream.h>,OK.
      

  2.   

    VC++6.0没有完全实现C++标准,它所提供的不带后缀.h头文件不支持把成员函数重载为友元函数。但是Visual C++ 6.0所提供的老形式的代后缀.h的头文件可以支持此项功能,因此可以将程序的头两行修改为#include <iostream.h>就可顺利运行(别忘了去掉using namespace std;)。
    不过打了SP6补丁的VC6.0或VC2003,VC2005不会出现这样的问题。类似情况都可以这么处理。