2012-04-16 16 views
1

我不知道什麼是錯的,但我不能訪問我的迭代器所指的對象的方法。這是我有:無法訪問multimap迭代器的方法?

multimap<long, Note>::iterator notesIT; 
notesIT = trackIT->getNoteList().lower_bound(this->curMsr * 1000000); 

while(notesIT->first/1000000 == 1){ 
    cout << notesIT->first.getStartTime() << endl; // error on this line 
    notesIT++; 
} 

我得到這個錯誤:

error: request for member 'getStartTime' in 'notesIT. std::_Rb_tree_iterator<_Tp>::operator-> [with _Tp = std::pair<const long int, Note>]()->std::pair<const long int, Note>::first', which is of non-class type 'const long int' 
+1

您希望第二個這樣使用 - >第二。 .. – 2012-04-16 00:10:13

+0

Distilled錯誤消息:「請求成員'getStartTime' ...在非類類型'常量長整型'」 – 2012-04-16 00:11:16

回答

1

編譯器會告訴你,

notesIT->first.getStartTime() 

無效因爲您正在嘗試撥打getStartTime()int。很顯然,你的意思是把它在Node,因此選擇對的第二部分的迭代器指向(即產生迭代器的Node部分):

cout << notesIT->second.getStartTime() << endl; 
+0

我應該看到。謝謝 – networkprofile 2012-04-16 00:23:32

4

也許:

notesIT->second.getStartTime()