From: "Tonetheman" Newsgroups: comp.lang.c++,comp.os.msdos.djgpp Subject: templated operator<< question Lines: 100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Message-ID: Date: Mon, 26 Apr 1999 01:41:06 GMT NNTP-Posting-Host: 24.92.75.207 X-Complaints-To: abuse AT midsouth DOT rr DOT com X-Trace: newse1.midsouth.rr.com 925090866 24.92.75.207 (Sun, 25 Apr 1999 20:41:06 CDT) NNTP-Posting-Date: Sun, 25 Apr 1999 20:41:06 CDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Does anyone have any ideas about what I am doing wrong in this code? Basically I am trying to re-use the STL set and I am not having much luck with the << operator. I have also listed the error listing that I get when trying to compile this sample program. It looks like the compiler cannot match the function signatures but from all I have read it looks right to me... If this is important I am using Windows 98 and DJGPP. Thanks for any information or pointers ahead of time. Tony #include #include using namespace std; template class sset : public set { public: friend ostream& operator<<(const sset& src, ostream &os); }; template ostream& operator<<(const sset& src, ostream & os) { set::iterator p = src.begin(); while(p!=src.end()) { os << *p << " "; } return os; }; int main() { sset testSet; testSet.insert(10); cout << testSet << endl; return 0; } Error listing is below:: mkuu2.cpp:10: warning: friend declaration `class ostream & operator <<(const class sset &, class ostream &)' mkuu2.cpp:10: warning: will not be treated as a template instantiation mkuu2.cpp:10: warning: unless you compile with -fguiding-decls mkuu2.cpp:10: warning: or add <> after the function name mkuu2.cpp: In function `int main()': mkuu2.cpp:30: no match for `_IO_ostream_withassign & << sset &' d:/djgpp/lang/cxx/iostream.h:108: candidates are: ostream::operator <<(streambuf *) d:/djgpp/lang/cxx/iostream.h:107: ostream::operator <<(ios & (*)(ios &)) d:/djgpp/lang/cxx/iostream.h:106: ostream::operator <<(ostream & (*)(ostream &)) d:/djgpp/lang/cxx/iostream.h:104: ostream::operator <<(long double) d:/djgpp/lang/cxx/iostream.h:100: ostream::operator <<(float) d:/djgpp/lang/cxx/iostream.h:99: ostream::operator <<(double) d:/djgpp/lang/cxx/iostream.h:97: ostream::operator <<(bool) d:/djgpp/lang/cxx/iostream.h:95: ostream::operator <<(short unsigned int) d:/djgpp/lang/cxx/iostream.h:94: ostream::operator <<(short int) d:/djgpp/lang/cxx/iostream.h:92: ostream::operator <<(long long unsigned int) d:/djgpp/lang/cxx/iostream.h:91: ostream::operator <<(long long int) d:/djgpp/lang/cxx/iostream.h:89: ostream::operator <<(long unsigned int) d:/djgpp/lang/cxx/iostream.h:88: ostream::operator <<(long int) d:/djgpp/lang/cxx/iostream.h:87: ostream::operator <<(unsigned int) d:/djgpp/lang/cxx/iostream.h:86: ostream::operator <<(int) d:/djgpp/lang/cxx/iostream.h:85: ostream::operator <<(const void *) d:/djgpp/lang/cxx/iostream.h:84: ostream::operator <<(const signed char *) d:/djgpp/lang/cxx/iostream.h:82: ostream::operator <<(const unsigned char *) d:/djgpp/lang/cxx/iostream.h:80: ostream::operator <<(const char *) d:/djgpp/lang/cxx/iostream.h:79: ostream::operator <<(signed char) d:/djgpp/lang/cxx/iostream.h:78: ostream::operator <<(unsigned char) d:/djgpp/lang/cxx/iostream.h:77: ostream::operator <<(char) mkuu2.cpp:10: operator <<(const sset &, ostream &)