TDirectory inheritance

From: William J Deninger (deninger@uiuc.edu)
Date: Fri Apr 03 1998 - 00:30:40 MEST


Hello,

Is is possible to have a class (say X) inherit TDirectory and still be accessible as its class type (X) with TDirectory functionality when written to a TFile?  I'm finding that once I close and reopen the file, the Class X object is gone and only the TDirectory portion remains.  How should I approach this problem?

// example
//___________________
class X : public TDirectory
{
public:
    X() : TDirectory();
    X(Text_t *name, Text_t *title) : TDirectory(name, title);
    virtual ~X();

    void Hi();
    ClassDef(X,1);
}  

//____________________
void X::Hi() { printf("hello to you too\n"); }
 //___________________

 the current keyboard layout is 437
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   1.03/09  16 December 1997   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

CINT/ROOT C/C++ Interpreter version 5.13.36, Nov 30 1997
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] f = new TFile("e:/data/g2trace;3.root","recreate");
root[1] X *x = new X("myx","my X class");
root[2] f.ls()
TFile**         e:/data/g2trace;3.root
 TFile*         e:/data/g2trace;3.root
  X*           myx        my X class
  KEY: TDirectory       myx;1    myx
root[3] x.Write();
root[4] f.Write();
TFile Writing Name=e:/data/g2trace;3.root Title=
root[5] .q

//__________________________________
the current keyboard layout is 437
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   1.03/09  16 December 1997   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************
 
CINT/ROOT C/C++ Interpreter version 5.13.36, Nov 30 1997
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] f = new TFile("e:/data/g2trace;3.root","update");
root[1] f.ls();
TFile**         e:/data/g2trace;3.root
 TFile*         e:/data/g2trace;3.root
  KEY: TDirectory       myx;1    myx
root[2] myx.Hi();
Error: No symbol myx.Hi() in current scope  FILE:D:\TEMP\466 LINE:1
*** Interpreter error recovered ***


William J Deninger
deninger@uiuc.edu



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