Re: ostream,..

Fons Rademakers (Fons.Rademakers@cern.ch)
Tue, 17 Feb 1998 16:39:51 +0100


Hi Selim,

did you export operator<< via your LinkDef.h? For friend functions you
have to add lines like:

#pragma link C++ function operator<<(ostream&,const TRange&);

to your LinkDef.h file, since friends are no class member functions
they will not be automatically included when TRange is exported.

Cheers, Fons.

Selim Issever wrote:
>
> Dear all,..
>
> I have a class, in which I want to control the way its output is done.
> Everything compiles well,.. and I can create TRange objects,.. but:
>
> root [0] TRange b
> root [1] cout << b << endl;
> root [2] cout << "hello" << endl;
> hello
> root [3]
>
> The code is below,.. what did I wrong again???
> ThanX and best regards
> Selim
>
> // --------------------------------------------------
> #ifndef TRange_H
> #define TRange_H
>
> #include <iostream.h>
> #include "/usr/local/root/include/TObject.h"
>
> class TRange : public TObject {
> public:
> [...delete...]
>
> friend ostream& operator<< (ostream& AStrm, const TRange& ARange) {
> AStrm << "hello";
> return AStrm;
> }
>
> ClassDef(TRange, 1) // A Variable that is connected to a TTree branch.
> private:
> [...delete...]
> };
> #endif //--------------------------------------------
>
> S E L I M I S S E V E R
> DESY-F15, Notkestr. 85, 22603 Hamburg, Germany; Tel/Fax: 040 8998-2843/4033
> http://www.physik.uni-dortmund.de/~issevers; selim.issever@desy.de
> Ete kemige burundum, Yunus diye gorundum. Yunus Emre

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910