std::map
を使用して、ラテンアルファベットの各文字にint
タイプ値を割り当てようとしています。私は新しいint型を作成し、それを言葉にマッピングされたint
に等しい値を与えたいときに、私はエラーを取得:エラー:charからconst key_typeへのユーザー定義の変換が無効です&
F:\Programming\korki\BRUDNOPIS\main.cpp|14|error: invalid user-defined conversion from 'char' to 'const key_type& {aka const std::basic_string&}' [-fpermissive]|
例:私は間違って何をやっている
#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;
}
?
@ juanchopanza - あなたが正しいです。しかし...私の答えはとても些細だった...削除されました。 – max66