I'm trying to compile a C++program(that ran in Linux before) in VC6. Here has the overloaded operator problem.
Code:
----------------------------------------------------------------------
aabb.h
=======
struct AABB
{
AABB();
AABB(const Vector3&, const Vector3&);
... ...
Vector3 bmin, bmax;
};
... ...
... ...
----------------------------------------------------------------------
bound.h
=======
class BoundBox : public AABB {
public:
......
inline BoundBox &operator= (const BoundBox &that) ;
inline BoundBox &operator+=(const BoundBox &that) ;
inline int operator==(const BoundBox &that)const;
};
(the global functions)
istream &operator>>(istream &buf, BoundBox &bb);
ostream &operator<<(ostream &buf,const BoundBox &bb);
... ...
----------------------------------------------------------------------
bound.cpp
========
... ...
istream &operator>>(istream &buf, BoundBox &bb) {
long orgFlags = buf.setf(ios::skipws);
eatChar('{',buf);
buf >> bb.bmin;
eatChar(',',buf);
buf >> bb.bmax;
eatChar('}',buf);
buf.flags(orgFlags);
return buf;
}
... ...
-----------------------------------------------------------------------
primitive.h
========
#include <iostream>
typedef std::ostream myostream;
typedef std::istream myistream;
(global functions)
myostream& operator << (myostream&, const Vector3&);
myistream& operator >> (myistream&, Vector3&);
... ...
------------------------------------------------------------------------
primitive.cpp
=========
... ...
myostream& operator << (myostream& out, const Vector3& v)
{
out << v.x << " " << v.y << " " << v.z;
return out;
}
myistream& operator >> (myistream& in, Vector3& v)
{
in >> v.x >> v.y >> v.z;
return in;
}
......
I can't find any problem of such overloading function. But it has compiling error.
bounds.cpp(78) : error C2678: binary '>>' : no operator defined which takes a left-hand operand of type 'class istream' (or there is no acceptable conversion)
bounds.cpp(80) : error C2678: binary '>>' : no operator defined which takes a left-hand operand of type 'class istream' (or there is no acceptable conversion)
That makes me confused for several days. Please help me. Thank you in advance~
Arwen.