Saving a class in a tree with CINT

Hi there,

In the piece of code below, data are not correctly registered with CINT (.x ztest.cpp(1) then .x ztest.cpp(0)) whereas they are if one uses ACLiC (.x ztest.cpp+(1) then .x ztest.cpp+(0)).
Is it a limitation or is there something to make this work with CINT?

Cheers,
Z (CentOS_5.6/ROOT_5.28.00c)

[code]
#include <TTree.h>
#include <TFile.h>
#include <TObject.h>

class TTest : public TObject
{
public:
Double_t x ;
public:
TTest () { x=-1. ; } ;
~TTest () { } ;
ClassDef (TTest,1) ;
} ;

void ztest ( Bool_t createData=kFALSE )
{
TTest * mytest = NULL ;
TTree * tree = NULL ;
TFile * froot = NULL ;

if ( createData )
{
mytest = new TTest () ;
tree = new TTree (“tree”,“test”) ;
tree->Branch(“test”,“TTest”,&mytest) ;
mytest->x = 3.14 ;
tree->Fill() ;
froot = new TFile (“mytest.root”,“recreate”) ;
tree->Write() ;
froot->Close() ;
} else {
mytest = new TTest () ;
froot = new TFile (“mytest.root”,“read”) ;
tree = (TTree*)froot->Get(“tree”) ;
tree->SetBranchAddress(“test”,&mytest) ;
tree->GetEntry(0) ;
printf ("\n\n%f\n\n",mytest->x) ;
froot->Close() ;
}

return ;
}[/code]

[quote]Is it a limitation or is there something to make this work with CINT?[/quote]It is a limitation, the I/O is not properly enabled for interpreted class (i.e. you must compile it via ACLiC for example).

Cheers,
Philippe.

Ok, thanks Philippe.
See you,
Z

PS: Will Cling manage this?

That is the intent (as even the ‘interpreted’ code will be passing through the compiler).

Cheers,
Philippe.