| | |
map<string,string> error
![]() |
•
•
Join Date: Nov 2008
Posts: 75
Reputation:
Solved Threads: 1
I need help with inserting a string for both key and value to a map.
error:
error: conversion from `std::_Rb_tree_iterator<std::pair<const std::string, std::string> >' to non-scalar type `std::_Rb_tree_iterator<std::pair<const std::string, int> >' requested
can you please help me with this.
thanks
drjay
C++ Syntax (Toggle Plain Text)
while(!myHuffFile.eof()){ string word, code; int freq; myHuffFile >> word >> freq >> code; if(word == ""){ break; }else{ _fileMap.insert(pair<string,string>(word,code)); _freqMap.insert(pair<string,int>(word,freq)); } }
error:
error: conversion from `std::_Rb_tree_iterator<std::pair<const std::string, std::string> >' to non-scalar type `std::_Rb_tree_iterator<std::pair<const std::string, int> >' requested
can you please help me with this.
thanks
drjay
•
•
Join Date: Nov 2008
Posts: 377
Reputation:
Solved Threads: 69
As written there is nothing wrong with this (except I think that you would benefit from a typedef. e.g.
However, I would guess that you have swapped the declarations of fileMap and freqMap.
It that is not the problem, please make a short test program and post that.
c++ Syntax (Toggle Plain Text)
typedef std::map<std::string,int> mTYPE; mTYPE aMap; //.... aMap.insert(mTYPE::value_type(word,i));
However, I would guess that you have swapped the declarations of fileMap and freqMap.
It that is not the problem, please make a short test program and post that.
Last edited by StuXYZ; Nov 30th, 2008 at 6:15 pm. Reason: error on code tag
![]() |
Similar Threads
- Help! STL map can not insert correctly (C++)
- Problem in inserting values in map containing vector of string (C++)
- Compilation error in graphml.cpp (C++)
- Problem in using Map (C++)
- Open In New Window Php (PHP)
- (was) STL <map> question (C++)
- Dr Scheme Tutorial (Computer Science)
- Is this due to being out of memory? (C)
- Linker Error in derived class initialization (C++)
- struct error (!?) (C)
Other Threads in the C++ Forum
- Previous Thread: helpppp
- Next Thread: How to read strings into 1D array and more?
| Thread Tools | Search this Thread |
api array based binary bitmap business c++ c/c++ char class classes code codesamplerunwhilecommands coding commentinghelp compile console conversion count decide delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error faq file forms fstream function functions game givemetehcodez graph guess gui hash homeworkhelp homeworkhelper iamthwee ifpug ifstream incrementoperators infinite input int integer java lib linkedlist linker listing loop looping loops map math matrix memory multiple news node output pointer port problem proficiency program programming project python random read recursion reference rpg string strings temperature template test text text-file tree url variable vector video win32 windows winsock wordfrequency wxwidgets





