•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 455,965 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,684 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1090 | Replies: 2 | Solved
![]() |
•
•
Join Date: Sep 2006
Location: Michigan State University, United States
Posts: 232
Reputation:
Rep Power: 3
Solved Threads: 1
Alright, here's the code:
and the error by g++ - (using make)
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:
I don't see the problem, apparently
Help!
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.Help!
Damn the man! Save the Empire!
•
•
Join Date: Dec 2006
Location: india
Posts: 1,084
Reputation:
Rep Power: 9
Solved Threads: 163
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 ) { /*...*/
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- JSP iterator error with structs (JSP)
- (was) STL <map> question (C++)
- STL <map> question? (C++)
- Is there a 'parent' stl container class? (C++)
- Run-time Error when printing Array Contents. (C)
- sorting stl::map (C++)
- Unknown Internet Explorer Issue (Viruses, Spyware and other Nasties)
- Internet Explorer error (Web Browsers)
Other Threads in the C++ Forum
- Previous Thread: Classes, Constructors, and Member Functions
- Next Thread: iterator addition - How does it work?



Linear Mode