Original Post
I'm getting a bizarre compiler error and I don't understand why it's happening. The compiler error: error C2593: 'operator <<' is ambiguous On the other hand, when I explicity cast the Array to a char* like so: ..it compiles fine, and when I get rid of the operator and write it out by hand, for example: ..it works fine; it's only with the 'operator <<(ostream&,const Entity&)' that I get ambiguity. Why is this happening?
template<class I> class Array {
public:
__inline operator I*() const {
return ptr;
}
...
};
class Entity {
public:
__inline const Array<char>& getName() const {
return name;
}
...
};
inline ostream& operator <<(ostream& out,const Entity& printMe) {
return out << printMe.getName();
}
...
return out << static_cast<char*>(printMe.getName());
cout << Array<char>("Hello, world.\n");