|
-
May 10th, 2006, 02:53 PM
#1
searching and then modifying element in a list
hi,
i have a set of numbers. now i want to search for a number and modify the match, if any found. so i code something like this...
set<int> list;
list.insert(1);
list.insert(2);
list.insert(3);
....
set<int>::iterator match = list.find(3);
if(match != list.end()) { // there is a match
*match = 7; // i want to modify the match to 7
}
however, it gives me a error since find() returns a const iterator and the contents cant be modifed.
do i need to convert my const interator (match) to a regular iterator. if so, how? are there other efficient ways to accomplish my goal?
thanks,
amit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|