This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: friend operators


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

Gokhan


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]