From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16228 invoked by alias); 27 Aug 2002 13:43:09 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 16220 invoked from network); 27 Aug 2002 13:43:07 -0000 Received: from unknown (HELO echem3.orgchemie.chemie.uni-tuebingen.de) (134.2.69.231) by sources.redhat.com with SMTP; 27 Aug 2002 13:43:07 -0000 Received: from uni-tuebingen.de (localhost [127.0.0.1]) by echem3.orgchemie.chemie.uni-tuebingen.de (8.11.6/8.11.6/SuSE Linux 0.5) with ESMTP id g7RCnJB03763; Tue, 27 Aug 2002 14:49:20 +0200 Message-ID: <3D6B754F.D92359D3@uni-tuebingen.de> Date: Tue, 27 Aug 2002 06:43:00 -0000 From: Bernd Speiser Reply-To: bernd.speiser@uni-tuebingen.de Organization: Univ. Tuebingen, Inst. f. Organische Chemie X-Accept-Language: en, de MIME-Version: 1.0 To: kisa@centropolisfx.com CC: gcc-help@gcc.gnu.org Subject: Re: friend operators References: <3D5BDF8D.2FBB3C04@uni-tuebingen.de> <3D6A6A4D.44296C48@centropolisfx.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-08/txt/msg00224.txt.bz2 Gokhan Kisacikoglu wrote: > > > void operator<< (string &); > > if you encapsulate it within a namespace, don't, it doesn't seem to > work, you should declare this operator globally for it to work, I've > seen this work with other compilers, but not with gcc... > Thanks for this information. However, I need the namespace in this case. I've kind of solved the problem in the meantime (following a suggestion mentioned in the gcc-bugs mailinglist: I declare ALL operator<< functions in this class to be friends. Of course, this means that those taking the class itself as a first argument, I have to give the class explicitly such as friend void operator<< (Quantity &, string &); friend istream & operator<< (Quantity &, istream &); so I can write Quantity Q; Q << "something"; istream is; Q << is; etc. Bernd > -- ======================================================================= Bernd Speiser Institut f"ur Organische Chemie Auf der Morgenstelle 18 D-72076 T"ubingen Germany phone: +49-7071-2976205 (office) +49-7071-2976242 (laboratory) fax: +49-7071-295518 e-mail: bernd.speiser@uni-tuebingen.de Internet: http://www.uni-tuebingen.de/speiser =======================================================================