Re: [ROOT] why arent the array classes derived from tobject ???

From: Valeri Fine (fine@bnl.gov)
Date: Thu Oct 11 2001 - 10:18:32 MEST


> hi rooters,
> 
> why arent the array classes derived from tobject ???
> 
> is there any danger to do 
> 
> TArrayD* DataArray=new TArrayD();
> fData->AddLast((TObject*)DataArray);

No  !!!! you can not do that.

 What you have to do is to create your own class like

 class myArray: public TObject, public TArrayD {
  . . .
 };

See for example http://root.cern.ch/root/htmldoc/TH1F.html

Maybe  you can find 
http://root.cern.ch/root/htmldoc/TGenericTable.html
useful to define your DataArray
and 
http://root.cern.ch/root/htmldoc/TDataSet.html
to define your fData

Try:

gSystem->Load("libStar");

struct data_t {
   double myDouble;
};

TDataSet *fData = new TDataSet("RootData");


Int_t startSize = 1000;
TGenericTable * DataArray = new TGenericTable("data_t","MyDataArray",startSize);

fData->Add(DataArray);

            Cheers, Valeri



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:02 MET