One thing that always bother me about CINT is that it does not alllow to define an array size by a variable, like
int a = 10;
int array[a];
Is there other way to define array size by variable without compiling the code, i.e. in root script?
Thanks.[/quote]
Yes, use for example std::vector. In C++ the array size must be a constant expression. And your question is quite strange, since CINT DOES ALLOW to declare an array of variable length (I’m not sure if it’s an extension or a part of its C-language support, since C has VLAs). If you try to compile this with compiler, you’ll have a compilation error or at least a warning, depending on compiler, since your ‘a’ is not a constant expression.
And in general, VLAs are not recommended (I guess because of way compiler vendors usually implement them), for example, have a look here:
[quote=“pamputt”]The same as tpochep. It is not allowed in C. You have to write
const int a=10;
int array[a];[/quote]
It’s allowed in modern C (with some differences and limitations), but not C++
P.S. Hmm, none of my compilers issues any diagnostic if an array size is a non-constant (g++ 4.8.1, clang 3.4), I have a warning only when compiling with ‘-pedantic’.