Array of void pointers

victor perevoztchikov (perev@mail.phy.ornl.gov)
Wed, 11 Jun 1997 14:26:27 -0400 (EDT)


Dear rooters,
could you explain such strange behaviour?

I have file myh1.C
1.
2. {
3. void *V[200];
4.
5. gROOT->Reset();
6.
7. c1 = new TCanvas("c1","The HSUM example",600,400);
8. c1->SetGrid();
9. c2 = new TCanvas("c2","The 2222 example",600,400);
10. c2->SetGrid();
11.
12.
13. // gBenchmark->Start("hsum");
14.
15. // Create some histograms.
16. total = new TH1F("total","This is the total distribution",100,-4,4);
17. main = new TH1F("main","Main contributor",100,-4,4);
18. s1 = new TH1F("s1","This is the first signal",100,-4,4);
19. s2 = new TH1F("s2","This is the second signal",100,-4,4);
20. total->Sumw2(); // this makes sure that the sum of squares of weights will be stored
21. total->SetMarkerStyle(21);
22. total->SetMarkerSize(0.7);
23. main->SetFillColor(16);
24. s1->SetFillColor(42);
25. s2->SetFillColor(46);
26.
27. V[1] = c1;
28. V[2] = c2;
29. V[3] = total;
30. V[4] = main;
31. V[5] = s1;
32. V[6] = s2
...

When I run it

root [0] .x myh1.C
Error: Array index out of range V[2]+2 valid upto V FILE:myh1.C LINE:28
*** Interpreter error recovered ***

It looks like that the real size of array V is less than declared 200.

Victor

-- 
-------------------------------------------------------------------------
Victor M. Perevoztchikov         perev@uther1.phy.ornl.gov  [ US
                                 perev@vxcern.cern.ch       [ CH
                                 perev@mx.ihep.su           [ RUS

Oak Ridge National Laboratory, MS 6374, Oak Ridge, TN 37831 (423-574 5928) Fax (423-576 5780) University of Tennessee, Knoxville, TN 37996-1200 (secre-at 423-974 3342) 9015 Ten Mile Rd. #209 Knoxville TN 37923 (423-693 2639)