public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernd Speiser <bernd.speiser@uni-tuebingen.de>
To: kisa@centropolisfx.com
Cc: gcc-help@gcc.gnu.org
Subject: Re: friend operators
Date: Tue, 27 Aug 2002 06:43:00 -0000	[thread overview]
Message-ID: <3D6B754F.D92359D3@uni-tuebingen.de> (raw)
In-Reply-To: <3D6A6A4D.44296C48@centropolisfx.com>

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
=======================================================================

      reply	other threads:[~2002-08-27 13:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-15 10:06 Bernd Speiser
2002-08-26 10:47 ` Gokhan Kisacikoglu
2002-08-27  6:43   ` Bernd Speiser [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D6B754F.D92359D3@uni-tuebingen.de \
    --to=bernd.speiser@uni-tuebingen.de \
    --cc=gcc-help@gcc.gnu.org \
    --cc=kisa@centropolisfx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).