コードは、2つの文字列が同じパターンを持っているかどうかを判断しようとします。
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
bool findMatch(char * s1, char * s2){
std::map<char, std::string> words;
std::istringstream iss(s1);
std::string word;
//for (std::string::size_t i = 0; i < s2.size(); ++i) //line 1
//for (int i = 0; i < s2.size(); ++i) //line 2
{
if (!(iss >> word))
return false;
std::string& mapping = words[s2[i]];
if (mapping == "")
mapping = word;
else if (mapping != word)
return false;
}
return !(iss >> word);
}
int main(int argc, char * argv[]){
bool b = findMatch("red blue blue red red yellow", "abbaac");
std::cout << b << std::endl;
return 0;
}
質問: 1行目と2行目の2回試行しましたが、どちらも機能しませんでした
1行目、エラー:クラス「...」にはメンバー「size_t」がありません
2行目:エラー:char*s2式はクラスタイプである必要があります
何か案は?