You're doing a number of things wrong.
char letter = 'A';
so far so good.
typedef pair<char, int> LettreValues;
Now you've gone south. You've defined a type alias ('typedef') for std::pair that is called "LettreValues".
But LettreValues is a type - not an instance of that type.
for (int i = 1; i < 27; ++i)
Since i
starts at 1
, the first value you insert into your map will be 'A' + 1.
LettreValues[letter]=i;
This attempts to use LettreValues
as a variable, which it is not; it tries to use it as a map, which is it not - it's a pair.
static_cast<char>(letter + 1);
This adds one to letter, converts it to a char, and discards it.
I think perhaps you were intending something like this:
// Declare an alias for std::map<char, int>.
using LettreValues = std::map<char, int>;
// Now declare a variable of this type
LettreValues letterValues;
// the type alias step is completely optional, we
// could have just written
// std::map<char, int> letterValues;
for (int i = 0; i < 26; ++i) {
letterValues[letter] = i;
letter++;
}
for (auto& el : letterValues) {
std::cout << el.first << " " << el.second << "\n";
}
Live demo: http://ideone.com/7ZA5Bk