I'm hoping someone can help clarify something for me here-I've done some digging around and I'm still confused as to why this isn't working.
I have a class that's in a namespace, and I'd like to overload the ostream operator to print some parameters that class holds in a formatted fashion. As a test I have (keeping things to a minimum):
You're putting your function body in the global namespace, not in the 'see' namespace.
Change it to this:
parameterfile.cc
1 2 3 4 5 6 7 8 9 10 11 12
usingnamespace std;
//using namespace see; <- bad
namespace see // <- good
{
std::ostream &operator<<(std::ostream &output, const see::ParameterFile ¶m){
output << "Overload test" << endl;
return output;
}
} // namespace see
As a general rule of thumb, using namespace xxx works for when you want to use things in the xxx namespace. When adding/modifying/defining things in the xxx namespace, you need actually be inside the namespace (ie: namespace xxx { } )