From: dontmailme AT iname DOT com (Steamer) Newsgroups: comp.os.msdos.djgpp Subject: Re: [HELP]: Template Question Date: Mon, 04 Dec 2000 10:34:25 GMT Organization: always disorganized Lines: 17 Message-ID: <3a2b72ff.6193680@news.freeserve.net> References: <3A2AE1BC DOT CEE72E58 AT vt DOT edu> NNTP-Posting-Host: modem-86.texas.dialup.pol.co.uk X-Trace: news8.svr.pol.co.uk 975926065 6179 62.137.94.86 (4 Dec 2000 10:34:25 GMT) NNTP-Posting-Date: 4 Dec 2000 10:34:25 GMT X-Complaints-To: abuse AT theplanet DOT net X-Newsreader: Forte Free Agent 1.11/32.235 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Farooq Azam wrote: > I need some help/sugegstions with compilation of the following code. It > compiles fine under MS-VC++ 6 and does not under g++ version 2.952. > template class Complex > { > friend ostream& operator << (ostream &output, const Complex &complex); This is the problem. You define this operator<< as a function template, but the above friend declaration refers to somthing that is not a function template specialization (just an ordinary function of the appropriate type). You need to insert into the friend delcaration: friend ostream& operator << (ostream &output, const Complex &complex); The C++ standard has an example in 14.5.3 paragraph 1 that explains this.