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);
};
自定义类中重载操作符后,调用时,编译提示错误:'operator <<' is ambiguous
解决方法:
VC6.0 需要先声明类和重载操作符
class Time;
ostream& operator<<(ostream& o, const Time& t);
VC 6.0 在SP3之前, 对iostream与friend有Bug, 需要patch----SP5。可能这样的错误与编译器有关吧。