【发布时间】:2018-06-29 08:53:24
【问题描述】:
我正在尝试在 C++ 中初始化字符串的二维数组。
std::string A = new std::string [m+1][n+1]
但这给了我错误,因为 new-expression 中的数组大小必须是常数。
【问题讨论】:
-
这是 C++,使用向量
std::vector<std::vector<std::string>> A(...)。 -
在 c++ 中你应该使用
std::vector或std::array而不是那些new any_type[m][n] -
VLA(C++ 中不存在可变长度数组)
标签: c++