Say I have a class A and an operator<< declared like so:
// A.h
class A
{
// A stuff
};
std::ostream& operator<<(std::ostream& os, co
Alan's suggestion of putting the user-defined operator in the std
namespace works. But I prefer putting the user-defined operator in the log4cxx::helpers
namespace, which also works. Specifically,
namespace log4cxx { namespace helpers {
ostream& operator<<(ostream& os, const A& a);
} }
I don't have a compiler available right now but i think the problem is caused by trying to use insert operator on a constant string. "A: " << a
You could try declaring your operator << in namespace std (that's legal, since you're passing an instance of your user-defined type):
namespace std {
ostream& operator<<(ostream& os, const A& a);
}