Многомерный массив размеров переменных в C ++C++

Программы на C++. Форум разработчиков
Anonymous
Многомерный массив размеров переменных в C ++

Сообщение Anonymous »

Я хочу сделать что -то вроде этого: < /p>
int op(string s1, string s2){
int x = s1.size();
int y = s2.size();
int matrix = new int[x][y]
/* do stuff with matrix */
}
< /code>
По какой -то причине я получаю следующие ошибки: < /p>
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


Подробнее здесь: https://stackoverflow.com/questions/194 ... array-in-c

Вернуться в «C++»