0

我正忙于阅读我的 C++ 书,似乎无法在没有错误“[Error] 'vector' is not declared in this scope”的情况下运行它

#include <iostream>
using namespace std;

int main(){
string word;
string previous;
string current;

vector<string> dislikes(4);
dislikes [0] = "bob";
dislikes [1] = "cat";
dislikes [2] = "pineapple";
dislikes [3] = "stackoverflow";

while(cin >> current){
for(i = 0; i<dislikes.size(); ++i){
    if(current==dislike[i]){
        cout << "BLEEP ";}

    else{cout << current << " "}

}   
    previous = current;
}

}
return 0;
}
4

1 回答 1

4

您需要包含矢量类型的头文件:

#include <vector>

在 C++ 中,所有内容都必须在用于代码之前进行声明,并且标准库的声明位于标准库头文件中。

于 2013-08-17T08:44:55.173 回答