Thomas Maeder wrote:
"Al-Burak" <[EMAIL PROTECTED]> writes:


Correction
I accidentally forgot to add the name of the namespace


As suspected.



--------- name.cpp
std::ostream& operator<<( std::ostream& os, const jme::Name& obj ) {
return os << obj.getNameStr(); }
std::istream& operator>>( std::istream& is, jme::Name& obj ) {
  return is >> obj.str;
}


This is your problem. As defined here, these operators belong to the
global namespace. But you want them to belong to the namespace jme:

namespace jme
{
  std::ostream &operator<<(std::ostream &os, Name const &obj)
  {
    return os << obj.getNameStr();
  }

  std::istream &operator>>(std::istream &is, Name &obj)
  {
    return is >> obj.str;
  }
}

and you should be fine.

Am I mistaken in thinking that the functions need to be declared in a header included by main.cpp? I see a "friend" declaration in name.hpp and a definition in name.cpp, but I thought a friend declaration alone did not imply a function declaration.
_______________________________________________
Help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to