delorie.com/archives/browse.cgi | search |
From: | "Tonetheman" <agcolston AT buckman DOT com> |
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: | <SuPU2.8517$XT1.392824@newse1.midsouth.rr.com> |
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 <iostream> #include <set> using namespace std; template <class A> class sset : public set<A> { public: friend ostream& operator<<(const sset<A>& src, ostream &os); }; template <class A> ostream& operator<<(const sset<A>& src, ostream & os) { set<A>::iterator p = src.begin(); while(p!=src.end()) { os << *p << " "; } return os; }; int main() { sset<int> 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<A> &, 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<int> &' 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<int> &, ostream &)
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |