有谁知道如何输出一个无序映射中的结构变量。我怎么能得到字典->例如单词
typedef struct dictionary{
std::string word;
unsigned char hash[20];
std::string hex;
} a_dictionary;
typedef std::unordered_map<std::string, dictionary*> Mymap;
std::unordered_map<std::string, dictionary* >::const_iterator got = c1.find(line);
if(out.is_open())
{
if ( got == c1.end() )
{
out << "????";
}
else
{
out << got->first << " , ";
}
}
}
最佳答案
迭代器的 second
成员是您指向 a_dictionary
结构的指针,因此只需像访问普通结构指针一样访问它:
out << got->first << " , " << got->second->word;
关于c++ - 输出无序映射中的结构变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15107208/