Creating an array of object

Maybe this is more a C++ issue than a ROOT one, but i thank you if you can answer me anyway.

I want to create dinamically an array of 20 TH1D object, but i don’t remember if:

is the correct way.

If yes, do i use correctly the member functions with e.g.

isto[3].Draw(); ?

And destroy with: delete isto[] ?

Moreover is possible to use also the constructor with arguments as:



TH1D* isto = new TH1D[20]; by

TH1D* isto = new TH1D*[20];
After this array allocation, create the individual histograms with

isto[0] = new TH1D("aaa0","aaa",100,0,100); isto[1] = new TH1D("aaa1","aaa",100,0,100); etc or for (int i=0;i<20;i++) { isto[i] = new TH1D(Form("aaa%d",i),"aaa",100,0,100); }
To delete these objects
-delete first all histograms

for (int i=0;i<20;i++) delete isto[i]; -then delete the array

delete [] isto;

I tried it now, but i have to use:

TH1D** isto = new TH1D*[20];

otherwise i get a crash.

Moreover to access methods of single histogram i have to use:


or (but only in interactive mode where this extension exists):



Yes, mea culpa, it must be;