What's wrong with TMyString ?

From: Nikolay I. Root (nroot@inp.nsk.su)
Date: Sun Jun 28 1998 - 23:14:31 MEST


     Dear ROOT team.

The following is my toy TObjString class :
--------------------------------------------------
#ifndef __TMyString_H__
#define __TMyString_H__

#include "TObject.h"
#include "TString.h"

class TMyString : public TObject, public TString {
public:
  TMyString()                  : TObject(),TString()   {};
  TMyString(Ssiz_t ic)         : TObject(),TString(ic) {};
  TMyString(TString& s)        : TObject(),TString(s)  {};
  TMyString(char* s)           : TObject(),TString(s)  {};
  TMyString(char c)            : TObject(),TString(c)  {};
  TMyString(char c, Ssiz_t s)  : TObject(),TString(c,s) {};
  TMyString(TSubString& sub)   : TObject(),TString(sub) {};
  TMyString(char* s, Ssiz_t n) : TObject(),TString(s,n) {};
  virtual ~TMyString() {};
  const char *GetName() const { return Data(); };
  ClassDef(TMyString,1)     // Toy TObjString class
};
#endif
----------------------------------------------------
I compile it to TMyString.so and load into root - OK.
I can write and read objects of TMyString to TFile - looks OK.
But when I insert TMyString* pointers to TList and retrive it back -
I cannot access the methods of TString part of TMyString !
Why ?
The following is a my 'root session' :
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   2.00/08       5 June 1998   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

CINT/ROOT C/C++ Interpreter version 5.13.55, May 16 1998
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] gSystem->Load("TMyString.so")
(int)0
root [1] TMyString s="abc"
root [2] s.Data()
(char* 0x855f28c)"abc"
root [3] s.Dump()
fUniqueID                0           object unique identifier
fBits                    50331648    bit field status word
*fData                   abc
root [4] TList *l=new TList()           
root [5] TMyString *p=new TMyString("a")
root [6] l->Add(p)
root [7] p=new TMyString("b")           
(class TMyString*)0x85c7e20
root [8] l->Add(p)           
root [9] p=new TMyString("c")
(class TMyString*)0x85c7de8
root [10] l->Add(p)           
root [11] l->Dump()
fUniqueID                0           object unique identifier
fBits                    50331648    bit field status word
*fData                   a
fUniqueID                0           object unique identifier
fBits                    50331648    bit field status word
*fData                   b
fUniqueID                0           object unique identifier
fBits                    50331648    bit field status word
*fData                   c
root [12] TMyString *o=l->FindObject("b")
root [13] o->ClassName()
(Text_t* 0x855f3ec)"TMyString"
root [14] o->GetName()  
(char* 0x85c7e54)"b"
root [15] o->Data()   
(char* 0x85c7e54)"b"
root [16] l->FindObject("b")->Data()     
Error: Can't call TObject::Data() in current scope FILE:/tmp/17810raa
LINE:1
Error: non class,struct,union object FindObject("b") used with . or ->
FILE:/tmp/17810raa LINE:1
*** Interpreter error recovered ***
root [17] l->FindObject("b")->GetName()
(Text_t* 0x85c7e54)"b"
root [18] l->FindObject("b")->ClassName()
(Text_t* 0x855f3ec)"TMyString"


Why CINT having correct ClassName cannot call to 'Data()' method ?

Best regards,
                               Nikolay Root
                               BINP, Novosibirsk
                               email : nroot@inp.nsk.su



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:34 MET