我创造了一款面向年轻观众的游戏,并试图过滤掉亵渎和冒犯的名字
#include <iostream>
#include <vector>
bool isBanned( std::string text ) {
std::vector bannedSent = {
"Profanity1",
"Profanity2",
"Profanity3",
"Profanity4"
};
for(auto &i : bannedSent) {
if(text == i) { return true; }
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
我在编写错误时谈到"模板参数",就行了std::vector,这是什么意思?