How Big Do You Want That Array, Sir?
In Java, arrays are allocated with new, with an expression
to give the size. This expression can be constant or variable.
In C and and C++, the situation is far too interesting.
- In C and C++, plain declarations, such as int fred;
must have a constant size.
- C99 allows a variable, but there is no such provision in C++.
- Arrays can be dynamically allocated.
- Since neither C nor C++ has garbage collection,
your program must free the space.
- In C, the calls are malloc, free and realloc.
- C++ addes new and delete.