矢量獲得價值爲什麼會在對的向量的迭代器訪問對的值時,下面的錯誤?錯誤從雙
vector< pair<int,string> > mapper;
if(Hash(input, chordSize) != id){
mapper.push_back(make_pair(tmp, input));
}
for (vector< pair<int,string> >::iterator it = mapper.begin(); it != mapper.end(); ++it)
{
cout << "1st: " << *it.first << " " // <-- error!
<< "2nd: " << *it.second << endl; // <-- error!
}
錯誤消息:
main_v10.cpp:165:25: error: ‘std::vector > >::iterator’ has no member named ‘first’ main_v10.cpp:165:56: error: ‘std::vector > >::iterator’ has no member named ‘second’
我該如何解決這個問題?
您可能想要讀取運算符優先級,簽出'*'和'.'優先權: http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B – billz 2013-02-15 07:58:52