lvb_qqqq_Profile.C (865 Bytes) lvb_qqqq_new.h (36.4 KB)
Hi Experts,
I am trying to make an array of 1-D histograms. On declaring them globally & defining them using a function, I found that I can fill the given array of histogram for index N exceeding the defined size of array without any error. I have attached my header & .C file .
For example, I declared
TH1F h3[3] ;
TH1F h4[3] ;
& defined them in another function
So I could easily done
h3[4].Fill(2.0);
Without any error. It is supposed to give error as the only upto index 2 for h3 defined.
I have attached my code so you could run it by yourself & see the problem. Let me know if anyone know the possible reason for this bizarre behaviour.
Arjun
P.S: In case you need it , commands to run
g++ -Wno-deprecated lvb_qqqq_Profile.C -o test.exe -I$ROOTSYS/include -L$ROOTSYS/lib root-config --cflagsroot-config --libs -std=c++11
./test.exe
Thanks for the reply. As you see in my code, I am ensuring that indices are correct. But irrespective of it , problem arises. So my question is that how is this possible ?
Arjun
The { /*...*/ } block in my previous post was not supposed to be dummy. It’s where you should put all your statements, e.g.: { std::cout << h_mcobject_pt[k]->GetName() << std::endl; }
But the main problem is, when I put output statement out of the loop for k > 7, I still get the output whereas it is supposed to give error.This is my problem.