Dynamic array container, with indirection.

How would I go about doing three levels of indirection with this array structure? I've never really messed with the array container and cannot find any examples for what I'm trying to do. Any help would be appreciated. I'm getting a constant value for size error, when trying to pass in SIZE.

1
2
3
4
int foo(int &row, int &column, const size_t &SIZE)
{
array<int, SIZE> ***s = new array< int, SIZE >**;
}
Last edited on
bump!
SIZE should be a compile-time constant, not just a const reference. You can define compile-time constants at global scope.

In other words: you can't pass SIZE of std::array as an argument of a function.
Last edited on
Why can I use,

1
2
3
int row = 5;
int *f;
f = new int[row];


But I cant do that with the array container?
It's by design. Arrays are intended to be fixed-size.

If you want a dynamically sized array, use 'vector' container instead of 'array'.
mishappp wrote:
I cant do that with the array container?

If you don't want the size to be fixed you should use the vector container.

http://www.cplusplus.com/reference/vector/vector/
Topic archived. No new replies allowed.