我創建了一個遊戲意味着年輕觀衆,我試圖篩選出褻瀆和冒犯名黑名單進攻句子
#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;
}
我得到一個編譯器錯誤談論「模板參數」,上線與std::vector
,這是什麼意思?
您忘記指定矢量的類型,即:'std :: vector' –
您可以使用佔位符輕鬆地替換令人討厭的文本以達到本示例的目的。 –
對於一個人來說,我有一個非常具體的東西,就像「希特勒沒有做錯什麼」一樣。 –