[ROOT] Variable array dimension

From: cstrato@EUnet.at
Date: Sat Apr 07 2001 - 23:48:53 MEST


Dear Rooters

In the CINT documentation there is the following statement:
 + constness of array dimension
   Variable dimension is not allowed in C/C++. Cint has special
capability to
  allow it only in interactive command and '{ ... }' style macro.

     void f() {
       int n=5;
       float a[n]; // this is error now
     }


Now I have the following compiled code which seems to work very well:
void MyClass::Calculate(Int_t size)   // size >= 1000
{
   Int_t len[size];
   for (i=0; i< size; i++) {
      len[i] = a_number;
   }//for_i
}

Now my questions:
1, Is my code correct or do I have to use “Int_t *len = new
Int_t[size]”?
2, If this is an error, why can I compile the code without problems?

My system: root3.00/06 on LinuxPPC

Thank you in advance
Best regards
Christian

----------------------------------
C.h.r.i.s.t.i.a.n  S.t.r.a.t.o.w.a
V.i.e.n.n.a.  A.U.S.T.R.I.A
e-mail: cstrato@EUnet.at



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:41 MET