Standard C++ does not have flexible array members (like C99 has).
You don't need your Array
class, use std::vector<int>
instead (or perhaps std::array
with C++11 if the array length is a compile time constant)
If you want to declare your Array
class containing Items
, follow the hints in the comment of Joachim Pileborg, learn about the rule of three (in C++11, it became the rule of five), so declare:
int *Items;
in your class, then initialize it with
Items = new int[n];
in its constructor[s], and destroy it with
delete [] Items;
in your destructor.