我的编译器提示。
#include <iostream>
#include <vector>
using namespace std;
int main(){
vector<string> vec[2];
vec[0].push_back("test1");
vec[0].push_back("test2");
cout << vec[0][0] << endl;
vec[0].erase(vec.begin());
cout << vec[0][1] << endl;
}
当我调用删除时出了什么问题?
最佳答案
vec
是 vector<string>
的数组s。我相信你的意思是 vec[0].begin()
像这样:
vec[0].erase(vec[0].begin());
关于c++ - 从 std::vector<std::string>> 中删除元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7784000/