Message-ID: <398326AF.4C7E65CE@puckbell.net> From: Wesel X-Mailer: Mozilla 4.73 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: friend/member function bug? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 64 Date: Sat, 29 Jul 2000 11:47:11 -0700 NNTP-Posting-Host: 63.197.122.98 X-Complaints-To: abuse AT pacbell DOT net X-Trace: news.pacbell.net 964895976 63.197.122.98 (Sat, 29 Jul 2000 11:39:36 PDT) NNTP-Posting-Date: Sat, 29 Jul 2000 11:39:36 PDT Organization: SBC Internet Services To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Is there a bug when you give friend functions and member functions the same name? I made this code: ------------------------------------------------ // In test.h #include using std::cout; template struct foo { Type bar; foo& operator<<(const Type& e) { bar = e; return *this; } friend ostream& operator<<<>(ostream& os,foo const& q); }; template inline ostream& operator<<(ostream& os,foo const& q) { foo const* temp = &q; return os << temp->bar << endl; } ------------------------------------------------ ------------------------------------------------ // In test.cpp #include "test.h" #include void main(void) { foo test; cout << test; } ------------------------------------------------ And got this compiler error: test.h: In instantiation of `foo': test.cpp:6: instantiated from here test.h:15: invalid use of undefined type `struct foo' test.h:16: forward declaration of `struct foo' test.h:15: confused by earlier errors, bailing out Someone suggested that gcc v. 2.95.2 has a bug when you try to declare operator<< as a friend and ::operator<< as a member. Is this true, and if so is there any way to work around it? Tasci -- To send me an email, just replace the @ and the . -----wassdamo at pacbell dot net