I get the error on trying to access the iterator reference:
QSet<UniqueWord>::iterator iter = uniqueWords.find(word);
iter->addOccurrence(position); // this gets an error
The error I get:
error: C2662: ‘UniqueWord::addOccurrence’ : cannot convert ‘this’
pointer from ‘const UniqueWord’ to ‘UniqueWord &’ Conversion loses
qualifiers
What am I missing?
You’re missing that the iterator’s
operator->returns aconst UniqueWord *, so you’re trying to calladdOccurrenceon aUniqueWordthat isconst.See the documentation here:
http://doc.qt.digia.com/qt/qset-iterator.html