Sorry,
There was an error in the script I sent you. I send you a new one with
FindObject calls instead of Get (and with the error fixed)
root [0] TObjString *mystr=new TObjString("mystr")
root [1] gDirectory->Add(mystr)
root [2] TMatrixD *mymatrix=new TMatrixD(1,1)
root [3] gDirectory->Add(mymatrix)
root [4] gDirectory->ls()
TROOT* Rint The ROOT of EVERYTHING
OBJ: TObjString mystr Collectable string class : 0 at: 0x8e5ae00
OBJ: TMatrixD TMatrixD Matrix class (double precision) : 0 at: 0x8ba8f40
root [5] gDirectory->FindObject(mystr->GetName())
(const class TObject*)0x8e5ae00
root [6] gDirectory->FindObject(mymatrix->GetName())
(const class TObject*)0x0
Thank you!
Pierre-Luc Drouin
On Wed, 13 Aug 2003, Rene Brun wrote:
> Pierre-Luc,
>
> I cannot reproduce this problem. Please send a short script.
>
> Rene Brun
>
> Pierre-Luc Drouin wrote:
> >
> > Hi,
> >
> > There is something I don't understand with TDirectory::Get(). Suppose I've
> > a
> > TNamed object and a object from a class that I've derived from
> > TNamed. Both objects have been added in gDirectory using
> > gDirectory->Add(). The object names are respectively "tnamed" and
> > "tnamedd". Why do I get this result:
> >
> > gDirectory->Get("tnamed") returns a pointer to the TNamed object
> > gDirectory->Get("tnamedd") returns a NULL pointer (not a pointer to the
> > TNamed derived object)
> >
> > If both objects are written a TKey into gDirectory, I get valid pointers
> > with the 2 lines
> >
> > I get also this problem with ROOT classes. With a TObjString object, I get
> > a valid pointer. With a TMatrixD object, I get a NULL
> > pointer.
> >
> > TDirectory::FindObject() behaves the same way (with objects in memory of
> > course)
> >
> > Thank you!
> >
> > Pierre-Luc Drouin
>
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET