class Time{
public:
int hour, minute, second;
public:
void set(int h, int m, int s){ hour=h, minute=m, second=s; }
friend Time& operator++(Time& a);
friend Time operator++(Time& a, int);
friend ostream& operator<<(ostream& o, const Time& t);
};
public:
public:
};
自定义类中重载操作符后,调用时,编译提示错误:'operator <<' is ambiguous
解决方法:
VC6.0 需要先声明类和重载操作符
class Time;
ostream& operator<<(ostream& o, const Time& t);
也就是:
google到一个解决方法,算是VC6的bug:
#include <iostream>
using namespace std;
class CA;
ostream &operator<<(ostream &output,CA &ca);
class CA
{
};
得提前声明