[ROOT] Multiple inheritance from TObject problem/ old cutoms class read/write problem

From: joer00@bellsouth.net
Date: Fri Jan 25 2002 - 15:20:37 MET


Rene, 

thanks for your example, I changed my class structure to this, but now when I call B.Write() I get the error "missing streamer on A dummy streamer called" which makes sense since each class should call its base class streamer and with the 0 in ClassDef A now has no streamer !

Joe

> 
> From: Rene Brun <Rene.Brun@cern.ch>
> Date: Wed, 23 Jan 2002 17:05:44 +0000
> To: joer00@bellsouth.net
> CC: roottalk@pcroot.cern.ch
> Subject: Re: [ROOT] Multiple inheritance from TObject problem/ old cutoms class read/write problem
> 
> I think that giving a simple example is better:
> 
> //-------file joe.cxx
> #include "TObject.h"
>    
> //-------------------------
> class A {
> 
> private:
>    int fA1;
>    int fA2;
> 
> public:
>    A() {fA1=1;fA2=2;}
>    ClassDef(A,0)
> };
> 
> //-------------------------
> //class B : public A, public TObject {   //<===wrong order
> class B : public TObject, public A {
>    
> private:
>    int fB1;
>    int fB2;
>    
> public:
>    B() {fB1=11;fB2=12;}
> 
> ClassDef(B,1)
> };
> 
> ClassImp(A)
> ClassImp(B)
> //------------end of jeoe.cxx
> 
> In interactive root, do
> root > .L joe.cxx++
> root > TFile f("junk.root","recreate");
> root > B b;
> root > b.Write("b");
> 
> ClassDef is mandatory for all classes involved in I/O.
> Specify ClassDef(A,0) if you do not want to write the members
> 
> Rene Brun
> 
> 
> joer00@bellsouth.net wrote:
> > 
> > Rene,
> > 
> > just to be 100 % sure now, from you posts this should work: (if yes just asnwer yes to save time, if no please explain because it than cotradicts with your provious posts !)
> > 
> > Class A does NOT deriver from TObject, does NOT define the ClassDef macros and has NO streamer. It HAS datamemebers which I do NOT want/need to write to disk.
> > 
> > Class B:public A,TObject
> > 
> > DOES deriver from TObject, DOES implement ClassDef, HAS a dictionary file,HAS data members which need to be written to disk.
> > 
> > BObject->Write("NAME"); and
> > BObject=(B*)SomeFile->Get("Name");
> > 
> >  WILL work although base class does NOT deriver from TObject and has no streamer !
> > 
> > Joe
>



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:40 MET