我试图在我的代码中使用一个字符串 vector 而不是一个字符串数组,但显然我在 vector 声明中遗漏了一些细节。使用以下代码,我收到此错误:‘vector’ was not declared in this scope
// Try to implement a vector of string elements
#include<iostream>
using namespace std;
int main() {
const int MAX_ITEMS = 10;
vector<string> my_vector(MAX_ITEMS);
return 0;
}
我应该如何正确声明 vector ?
最佳答案
你应该添加这些包括:
#include <vector>
#include <string>
关于c++ - 如何在 C++ 中声明 vector ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2303435/