std::vector<std::string> myList = new std::vector<std::string>();
如上所述分配内存会不会错?我知道内存是动态分配的,但只是想知道是否可以使用new运算符分配内存。
是的因为new std::vector<std::string>()返回一个指针,而在左侧你没有指针。
new std::vector<std::string>()
这没什么不对
std::vector<std::string> myList;
不需要new。
new