1

何が問題なのかわかりませんが、イテレータが参照しているオブジェクトのメソッドにアクセスできません。これは私が持っているものです:

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'
4

2 に答える 2

4

多分:

notesIT->second.getStartTime()
于 2012-04-16T00:10:52.140 に答える
0

コンパイラはそれを教えてくれます

notesIT->first.getStartTime()

を呼び出そうとしているため、 は無効getStartTime()ですint。明らかに、あなたはそれを a で呼び出すつもりNodeだったので、イテレータが指すペアの 2 番目の部分を選択します (イテレータのNode部分を生成します)。

cout << notesIT->second.getStartTime() << endl;
于 2012-04-16T00:14:48.107 に答える