public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernd Speiser <bernd.speiser@uni-tuebingen.de>
To: gcc-help@gcc.gnu.org
Subject: friend operators
Date: Thu, 15 Aug 2002 10:06:00 -0000	[thread overview]
Message-ID: <3D5BDF8D.2FBB3C04@uni-tuebingen.de> (raw)

Hi,
I´m still using gcc 2.95.3 on a SuSE Linux 7.3 system.

I´m trying to write some C++ code which uses operator overloading in a
friend situation. Also this is within a template (but I have already
observed all requirements pointed to in the FAQ, so this is ok, and the
problem also appears in non-template classes).

When I have a declaration like

friend ostream & operator<< (ostream &, VariableQuantity<U, D> &);

and I declare later another operator<< with different argument types,
e.g.

void operator<< (string &);

this does not work if the second operator<< is NOT a friend.
Then I get the error message

../Quantity/Quantity.h: In instantiation of `Quantities::VariableQuantity<Units:
:QuantityUnit<Quantities::LengthUnitClass>,Dimensions::QuantityDimension<Quantit
ies::LengthDimensionClass> >':
Length.h:431:   instantiated from here
../Quantity/Quantity.h:852: invalid use of undefined type `class Quantities::Var
iableQuantity<Units::QuantityUnit<Quantities::LengthUnitClass>,Dimensions::Quant
ityDimension<Quantities::LengthDimensionClass> >'
../Quantity/Quantity.h:907: forward declaration of `class Quantities::VariableQu
antity<Units::QuantityUnit<Quantities::LengthUnitClass>,Dimensions::QuantityDime
nsion<Quantities::LengthDimensionClass> >'
../Quantity/Quantity.h:852: confused by earlier errors, bailing out

when I try to instantiate the template (or, if this is not a template class, if
I just want to use the class).
If the second operator<< is also a friend, it compiles ok.

Is there something illegal about my code?

Thanks for any help.
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 (new!)
e-mail: bernd.speiser@uni-tuebingen.de
Internet: http://www.uni-tuebingen.de/speiser
=======================================================================

             reply	other threads:[~2002-08-15 17:06 UTC|newest]

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

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=3D5BDF8D.2FBB3C04@uni-tuebingen.de \
    --to=bernd.speiser@uni-tuebingen.de \
    --cc=gcc-help@gcc.gnu.org \
    /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).