Alright, here's the code:

for ( map<string,int>::iterator word = mostUsed.begin() ;
		word != mostUsed.end() ; word++ )

and the error by g++ - (using make)

error: conversion from 'std::_Rb_tree_const_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >; int> >' to non-scalar type 'std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >; int> >' requested

Okay... what in the name of the gods? I used this code before in the program and nothing screwed up. here's that for-loop:

for( map<string,int>::iterator x = fauxIn.begin() ; x != fauxIn.end() ; x++ )

I don't see the problem, apparently map<string,int>::iterator word = mostUsed.begin() is the problem, but I don't see anything wrong.


mostUsed is a const. use a const_iterator. also a prefix increment instead of a postfix (efficiency)

for ( map<string,int>::const_iterator word = mostUsed.begin() ;
		word != mostUsed.end() ; ++word ) { /*...*/
Impressive advise, Glad I got your help.

Wow, thanks! That allowed me to compile for the first time in a month. ^_^ I wouldn't have thought to make it a const_iterator instead of a regular iterator.


This question has already been answered. Start a new discussion instead.