The following code does not work: It gives an error —> [color=red]error: request for member ‘Add’ in ‘Hlist’, which is of non-class type ‘TObjArray*’
[/color]
How can I fix this?
[color=darkblue]…bunch of includes…
using namespace std;
char name[10], title[20];
int main(int argc, char **argv)
{
TObjArray Hlist(0); // create an array of Histograms
TH1F h; // create a pointer to a histogram
// make and fill 15 histograms and add them to the object array
for (Int_t i = 0; i < 15; i++) {
sprintf(name,“h%d”,i);
sprintf(title,“histo nr:%d”,i);
h = new TH1F(name,title,100,-4,4);
Hlist.Add(h);
h->FillRandom(“gaus”,1000);
}
// open a file and write the array to the file
TFile f(“out.root”,“recreate”);
Hlist->Write();
f.Close();
return 0;
}[/color]