Multiple inheritance from TObject


I am very very beginner of both C++ and ROOT… and I have the following problem.

I have a shared library, containing the definition of some classes (that inherit from Object and include the ClassDef and ClassImp macros), generated by following the standard procedure (by invoking rootcint etc.).
Each one of this classes is used to create and fill a tree, where my data are stored.

I defined a class that inherits from all these classes, becouse I need to combine their information and this is very easy by using inheritance.
However this creates ambiguity problems with rootcint, due to the fact that all the parent classes inherit from the same base class, TObject. (While I have no problems with normal c++ compiler)

Question 1:
Is there a way to convince rootcint to create the dictionary for this class and generate a library that can be easily accessed through the interpreter with the method System->Load(“”)?

Question 2:
If the answer to the previous question is no, is there an easy way to use anyway this class during an interactive ROOT session?

The only thing I could manage to do is to use the directive
#include "my-class-implementation.h"
inside my macros.
This could be fine… but every time I open a session I have to set “by hand” the include path typing the command:
.include -I/my-inlcude-path/
This I don’t like too much…
I would like to find a more general procedure.

Did someone faced a similar problem or can tell me were to look for?



Cint supports multiple inheritance - ROOT itself uses it. What’s more problematic is your case of diamond inheritance, where two base classes share in turn the same base class - lookup and member layout is extremely problematic, even without ROOT (google for “diamond inheritance” for details).

The only solutions I see are

  • use virtual inheritance (see google “diamond inheritance virtual”),
  • change your class layout, e.g. by changing the current base classes into members of the combining class
  • don’t derive the base classes from TObject (like the TAtt* classes for ROOT).

By the way, you can set the .include path by putting e.g. gSystem->ProcessLine(".include myIncPath") into your ./rootlogon.C.

Cheers, Axel.