Initialize 2d Array at compile and allow user input

  adjacency-matrix, arrays, c++, gcc, multidimensional-array

I am trying to declare an array that is sized at runtime/compile through an overload constructor.

private:
auto** arr = new int[n][n];


overloadConstruct(int n){
arr[n][n] = {0,0};
}

This does not work, it says the second n needs to be constant and auto is not allowed. Any help would be appreciated. I am not sure of all the rules with arrays, especially 2d arrays when doing this. I just need to be able to size a 2d array at runtime/compile through an input.

Source: Windows Questions C++

LEAVE A COMMENT