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 a const UniqueWord *
, so you're trying to call addOccurrence
on a UniqueWord
that is const
.
See the documentation here:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.