Re: rootcint and multiple inheritance

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sun Feb 13 2000 - 10:43:33 MET


Hi Valeri,

Yes, this is possible. see your files slightly modified below:
Run the script creating the shared lib test.so, then run the session:
Root > gSystem->Load("test");
Root > Bclass b;
Root > b.Dump();

Rene Brun

//----script to create a small shared lib on Linux
rootcint -f testcint.cxx -c test.h LinkDef.h
g++ -g -fPIC -I$ROOTSYS/include -c testcint.cxx test.cxx
g++ -g -Wl,-soname,test.so -shared testcint.o test.o -o test.so 


//----LinkDef.h file
#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class Bclass;

#endif


//-----test.h
#include "TObject.h"

class Aclass
{
 private:
  int   a_member;

 public:
  Aclass(){}
  virtual ~Aclass(){}

  //  ClassDef(Aclass,1)   // if this line commented - a_member is hidden
from root
};

class Bclass
      :public TObject
      ,public Aclass
{
  private:
  int b_member;

 public:
  Bclass();
  virtual ~Bclass(){}

  ClassDef(Bclass,1)
};

//-------test.cxx file
#include "test.h"
   ClassImp(Bclass)
   
Bclass::Bclass() :Aclass()
{
   b_member = 1234;
}


On Wed, 9 Feb 2000, Valeri Tioukov wrote:

> Hi Rooters,
> 
> If I have class  Aclass  used by external application and I do not want to
> do ANY changement in this class, but I'd like to make it's memebers and
> functions visible to Root system (for storage and analisys purpose)
> inheriting new Bclass as following:
> 
> class Bclass
>       :public TObject
>       ,public Aclass
> 
> Is it possible?
> 
> I investigate that without including macros   ClassDef(Aclass,1) into the
> body of Aclass  rootcint do not generate  Streamer() and  
> ShowMembers() functions. Just mentioning of Aclass in LinkDef.h do not
> helps.
> 
> So it seems that the answer is NOT: it is not possible to make the members
> of classA visible to Root without changements of classA body.
> 
> But the same question was asqued at least twice:
> 
> http://root.cern.ch/root/roottalk/roottalk98/1986.html
> http://root.cern.ch/root/roottalk/roottalk98/0107.html
> 
> and in both cases the answers were a bit confusing but positive.
> 
> Why do not find the definite answer and add it to FAQ? 
> 
> I used for tests:
> ----------------test.h------------
> #include "TObject.h"
> 
> class Aclass
> {
>  private:
>   int   a_member;
> 
>  public:
>   Aclass(){}
>   virtual ~Aclass(){}
> 
>   //  ClassDef(Aclass,1)   // if this line commented - a_member is hidden  from root
> };
> 
> class Bclass
>       :public TObject
>       ,public Aclass
> {
>   private:
>   int b_member;
> 
>  public:
>   Bclass():Aclass(){}
>   virtual ~Bclass(){}
> 
>   ClassDef(Bclass,1)
> };
> -----------------------------------
> 
> ---------LinkDef.h----------------------
> #ifdef __CINT__
> 
> #pragma link off all globals;
> #pragma link off all classes;
> #pragma link off all functions;
> 
> #pragma link C++ class Aclass;
> #pragma link C++ class Bclass;
> 
> #endif
> ---------------------------------------
> 
> 
> Without the commented line command
> 
>  >  rootcint -f test_h.C -c test.h LinkDef.h
> 
> do not care about members of Aclass.
> 
> 
> Best regards
> Valeri
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET