Re: TNamedObjArray

Martin Woudstra (woudstra@nikhef.nl)
Tue, 25 Feb 1997 15:26:29 +0100


Jacek M. Holeczek wrote:
>
> Hi,
> I just tried to create a small TNamedObjArray :
> ----------------------------------------------- TNamedObjArray.h BEGINs here
> #ifndef ROOT_TNamedObjArray
> #define ROOT_TNamedObjArray
>
> #ifndef ROOT_TNamed
> #include "TNamed.h"
> #endif
>
> #ifndef ROOT_TObjArray
> #include "TObjArray.h"
> #endif
>
> class TNamedObjArray : public TNamed, public TObjArray {
>
> public:
> TNamedObjArray();
> TNamedObjArray(Text_t *name, Text_t *title,
> Int_t s = TCollection::kInitCapacity, Int_t lowerBound = 0);
> ~TNamedObjArray();
>
> ClassDef(TNamedObjArray,1) //The class title
> };
>
> #endif
> ----------------------------------------------- TNamedObjArray.h ENDs here
> ----------------------------------------------- TNamedObjArray.C BEGINs here
> //
> // An ObjArray with a Name
> //
>
> #include "TNamedObjArray.h"
>
> ClassImp(TNamedObjArray)
>
> TNamedObjArray::TNamedObjArray():TNamed(),TObjArray() {}
>
> TNamedObjArray::TNamedObjArray(Text_t *name, Text_t *title,
> Int_t s, Int_t lowerBound)
> :TNamed(name,title),TObjArray(s,lowerBound)
> {}
>
> TNamedObjArray::~TNamedObjArray() {}
> ----------------------------------------------- TNamedObjArray.C ENDs here
> Unfortunately when compiling the dictionary ( created by rootcint )
> TNamedObjArray_dict.C I get 5 times the following error :
> "TNamedObjArray_dict.C", line 172.17: 1540-117: (S) "TNamedObjArray"
> has more than one base class "TObject".
> in following places :
> twice from "* virtual base class offset calculation interface"
> twice from "* Inheritance information setup/"
> once from "// Read a pointer to an object of class TNamedObjArray."
> Seems I am doing something stupid here. What ?
> Thanks in advance,
> Jacek.

You inherit from both TNamed and TObjArray, which both are
derived from TObject. So you inherit twice from TObject.
I am not sure if according to the C++ standard the compiler
should accept this or not.

Regards,

Martin.

Additional request to the developers:

TNamedObjArray could at the same time be an array of TNamed objects,
with search and get facilities using the name of the objects in the
array. It would then be a kind of a TMap with the name of the object
used as a key.
This would be very useful, I think, because I use TMap mostly because
I want a string as a key, instead of just an integer.
It should not be too difficult to make this.

Regards,
Martin.