I am trying to assign int type value to each letter in latin alphabet using std::map. When I want to create new int and give it a value equal to int mapped to word, i get an error:
F:\Programming\korki\BRUDNOPIS\main.cpp|14|error: invalid user-defined conversion from 'char' to 'const key_type& {aka const std::basic_string&}' [-fpermissive]|
Example:
#include <iostream>
#include <string>
#include <cstdlib>
#include <map>
using namespace std;
int main()
{
std::map <std::string,int> map;
map["A"] = 1;
int x;
std:: string word = "AAAAAA";
x = map[word[3]]
cout << x;
return 0;
}
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire