I am working on an application that tracks the frequency of letters in a string. To do this I created the following Struct
struct MessageLetter{
char letter;
int count;
MessageLetter(char letter, int freq)
: letter(letter), count(freq)
{}
};
Now I am trying to create a stl::map like follows...
std::map<std::string, MessageLetter> lList;
for(int i = 0; i < output.length(); i++){
std::cout << i << output[i] << std::endl;
if(lList.find(output[i]) == lList.end()){
std::cout << "Letter not found" << std::endl;
MessageLetter m = {output[i],1};
lList[output[i]] = m;
}
else{
std::cout << "Letter found" << std::endl;
}
}
When I try to compile this I get the following...
test.cpp:95:8: error: no template named 'map' in namespace 'std'; did you mean 'max'?
std::map<std::string, MessageLetter> lList;
I am new to c++ so any guidance would be great. And if this is a duplicate I will be happy to remove. Any other information (C++ version etc) will be provided if needed. This is eventually going to be a native Android app.
#include <map>
问题解决了。
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.