hi I want to do something like this:
int op(string s1, string s2){
int x = s1.size();
int y = s2.size();
int matrix = new int[x][y]
/* do stuff with matrix */
}
For some reason I get the following errors:
SuperString.cpp(69) : error C2540: non-constant expression as array bound
SuperString.cpp(69) : error C2440: 'initializing' : cannot convert from 'int (*)[1]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
SuperString.cpp(71) : error C2109: subscript requires array or pointer type
Thanks!
Best Answer
Here is a summary of how to build a 2d array in C++ using various techniques.
Static 2D Matrix:
Dynamic 2d Matrix:
Matrix using std::vector:
3d matrix using boost::multi_array (taken from boost multi_array docs):