I encountered a problem when tried compiling the following code:
#include
#include
#include
#include
You cannot execute arbitrary expressions at global scope, so
mapDial['A'] = 2;
is illegal. If you have C++11, you can do
map mapDial {
{ 'A', 2 }
};
But if you don't, you'll have to call an initialisation function from main
to set it up the way you want it. You can also look into the constructor of map
that takes an iterator, and use that with an array in a function to initialise the map, e.g.
map initMap() {
static std::pair data[] = {
std::pair('A', 2)
};
return map(data, data + sizeof(data) / sizeof(*data));
}
map mapDial = initMap();