Hi,
There is a very small bug that prevents the TClonesArray to properly detect the
name of the base class (if the base class is inside a namespace or another class).
There is no quick fix beside not using namespace or applying the patch below.
Philippe.
diff -r1.1.1.1 TBaseClass.cxx
83c83
< return fInfo->Name();
---
> return fInfo->Fullname();
> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of thorsten glebe
> Sent: Tuesday, November 21, 2000 9:57 AM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] namespace problem
>
>
> Hello,
>
> I have a problem using namespace. If I define two classes
> (MyClass, MyLeaf) inside a namespace (e.g. namespace TG),
> with MyLeaf inherited from MyClass, and MyClass inherited from TObject,
> then root forgets that MyLeaf is inherited from TObject, too.
>
> MyLeaf looks fine with the .class command, but using
> the ClassDraw() command, MyLeaf looks like a base class.
> Even worse, when trying to save a MyLeaf Object-Pointer
> in a TClonesArray I get the following error:
>
> Error in <TClonesArray::TClonesArray>: TG::MyLeaf does not inherit
> from TObject
>
> I am using root version 2.25.03.
>
> Is there a solution to this problem?
>
> Goodbye,
> Thorsten
>
>
> Code: (MyClass.hh)
>
> #include <TObject.h>
>
> namespace TG {
>
> class MyClass : public std::TObject {
> public:
> MyClass();
>
> int Loop();
>
> ClassDef(MyClass,1)
> };
>
>
> class MyLeaf : public MyClass {
> public:
> MyLeaf();
> int print();
>
> ClassDef(MyLeaf,1)
> };
> } // end of namespace
>
>
> MyClass.C:
>
> #include <iostream>
> #include "MyClass.hh"
>
> namespace TG {
>
> MyClass::MyClass() {
> std::cout << " MyClass constructor" << endl;
> }
>
> int MyClass::Loop() {
> cout << " Myclass loop " << endl;
> return 0;
> }
>
> ClassImp(MyClass)
>
> MyLeaf::MyLeaf() {
> std::cout << " MyLeaf constructor" << endl;
> }
>
> int MyLeaf::print() {
> cout << " MyLeaf loop " << endl;
> return 0;
> }
>
> ClassImp(MyLeaf)
>
> }
>
>
> LinkDef.h:
>
> #ifdef __CINT__
>
> #pragma link off all globals;
> #pragma link off all classes;
> #pragma link off all functions;
>
> #pragma link C++ nestedclasses;
> #pragma link C++ nestedtypedefs;
>
> #pragma link C++ namespace TG;
> #pragma link C++ class TG::MyClass;
> #pragma link C++ class TG::MyLeaf;
> #endif
>
>
> ----------------------------------------------------
> Dr. Thorsten Glebe <Thorsten.Glebe@mpi-hd.mpg.de>
>
> Max-Planck-Institut fuer Kernphysik
>
> Saupfercheckweg 1 Tel: 06221/516-631
> D-69117 Heidelberg Fax: 06221/516-603
> ----------------------------------------------------
>
>
>
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:37 MET