   ostream overloading
  I've got a program the overloads the << operator.  However it's generating some errors and I'm not sure why.My class...   class Word{char Letters[40];public:Word();Word(const Word &);Word(const char *);~Word();const char *GetString();const Word &operator=(const Word &);bool operator<(const Word &) const;bool operator>(const Word &) const;bool operator<=(const Word &) const;bool operator>=(const Word &) const;bool operator==(const Word &) const;bool operator!=(const Word &) const;friend ostream &operator<<(ostream &, const Word &);};The methods   #include <iostream>#include <string>using namespace std;#include "word.h"Word::Word(){for(int i = 0; i < 40; i++){Letters[i] = '\0';}}Word::Word(const Word &rhs){strcpy(Letters, rhs.GetString());}Word::Word(const char *rhs){if(rhs == NULL){for(int i = 0; i < 40; i++){Letters[i] = '\0';}}else{strcpy(Letters, rhs);}}Word::~Word(){}const char *Word::GetString() const{return Letters;}ostream &Word::operator<<(ostream &ost, const Word &WordOut){ost << WordOut.GetString();return ost;}const Word &Word::operator=(const Word &rhs){const char *rhString = rhs.GetString();strcpy(Letters, rhString);return *this;}bool Word::operator<(const Word &rhs) const{int Value = strcasecmp(Letters, rhs.GetString());bool RetVal = false;if(Value < 0){RetVal = true;}return RetVal;}bool Word::operator>(const Word &rhs) const{int Value = strcasecmp(Letters, rhs.GetString());bool RetVal = false;if(Value > 0){RetVal = true;}return RetVal;}bool Word::operator<=(const Word &rhs) const{int Value = strcasecmp(Letters, rhs.GetString());bool RetVal = false;if(Value == 0 || Value < 0){RetVal = true;}return RetVal;}bool Word::operator>=(const Word &rhs) const{int Value = strcasecmp(Letters, rhs.GetString());bool RetVal = false;if(Value == 0 || Value > 0){RetVal = true;}return RetVal;}bool Word::operator==(const Word &rhs) const{int Value = strcasecmp(Letters, rhs.GetString());bool RetVal = false;if(Value == 0){RetVal = true;}return RetVal;}bool Word::operator!=(const Word &rhs) const{int Value = strcasecmp(Letters, rhs.GetString());bool RetVal = false;if(Value != 0){RetVal = true;}return RetVal;}Everything looks okay to me... but I keep getting these errors.g++ -Wall -c word.cppword.cpp:51: `std::ostream& Word::operator<<(std::ostream&, const Word&)' must   take exactly one argumentword.cpp:51: no `std::ostream& Word::operator<<(std::ostream&, const Word&)'   member function declared in class `Word'word.cpp: In member function `std::ostream& Word::operator<<(std::ostream&,   const Word&)':word.cpp:52: no matching function for call to `Word::GetString() const'word.cpp: In member function `const Word& Word::operator=(const Word&)':word.cpp:60: no matching function for call to `Word::GetString() const'word.cpp: In member function `bool Word::operator<(const Word&) const':word.cpp:70: no matching function for call to `Word::GetString() const'word.cpp: In member function `bool Word::operator>(const Word&) const':word.cpp:84: no matching function for call to `Word::GetString() const'word.cpp: In member function `bool Word::operator<=(const Word&) const':word.cpp:98: no matching function for call to `Word::GetString() const'word.cpp: In member function `bool Word::operator>=(const Word&) const':word.cpp:111: no matching function for call to `Word::GetString() const'word.cpp: In member function `bool Word::operator==(const Word&) const':word.cpp:126: no matching function for call to `Word::GetString() const'word.cpp: In member function `bool Word::operator!=(const Word&) const':word.cpp:140: no matching function for call to `Word::GetString() const'The most pressing problem is the errors generated by trying to overload the ostream operator.  I cna't figure ou the problem there as well as the odd errors generated as a result of calling GetString(), I've been at this for hours and I can't figure this out either.  Anyone have any ideas?   I know only that which I know, but I do not know what I know. [edited by - Daishi on February 15, 2004 11:39:06 PM]
  Try changing:ostream &Word::operator<<(ostream &ost, const Word &WordOut) {ost << WordOut.GetString();return ost;}  to:ostream & operator<<(ostream &ost, const Word &WordOut) {ost << WordOut.GetString();return ost;}  operator<<(ostream &, const Word &) is a non-member friend of class Word, and shouldn't be declared in Word's scope.edit: formatting   [edited by - SiCrane on February 15, 2004 11:42:50 PM];  Thanks.  I didn''t catch that.  That also stopped the errors on the GetString() function, anyone know why these errors would appear in functions completely unrelated to the ostream function?   I know only that which I know, but I do not know what I know.;  Probably the compiler just got really confused by the operator<<() appearing in the wrong scope and it borked some symbol tables. It''s a suprisingly common occurance. That is to say, often an error early in the file can make perfectly good code later in the file look bad to the compiler. 