I want to overload operator<<
for my class. Should I add this overloaded definition to the std
namespace? (since the ostream operator<<
is part of the std
namespace) Or should I just leave it in the global namespace?
In short:
class MyClass {
};
namespace std {
ostream& operator<< ( ostream& Ostr, const MyClass& MyType ) {}
}
OR
class MyClass {
};
std::ostream& operator<< ( std::ostream& Ostr, const MyClass& MyType ) {}
Which is more appropriate and why? Thanks in advance for your responses.
See Question&Answers more detail:os