Problem with array declaration

Hi,

I want to declare an array whose size depends on the bin number of a histogram. Consider the following macro:

#include "TH1F.h"
void test(){
// // These two lines work
//   TH1F h("","",10,0,10);
//   const int Nbin = h.GetNbinsX();

//   These two lines give an error
  TH1F *h = new TH1F("","",10,0,10);
  const int Nbin = h->GetNbinsX();

  int MyArray[Nbin];
}

Executing this in CINT, i.e. root test.C, gives this error message when the histogram is declared as a pointer:

It works ok if the histogram is declared as TH1F h(“”,“”,10,0,10);

Both version work fine if I compile with ACLiC,
root test.C++

Thanks for explanations,
Jochen

… funny enough, I can overcome the problem by doing the following:

#include "TH1F.h"
void test(){
  TH1F *h = new TH1F("","",10,0,10);
  const int N = h->GetNbinsX();
  const int Nbin = N;

  int MyArray[Nbin];
}

Jochen