How to declare std map constants i.e.,
int a[10] = { 1, 2, 3 ,4 };
std::map <int, int> MapType[5] = { };
int main()
{
}
In the about snippet it is possible to give values 1,2,3,4 to integer array a, similarly how to declare some constant MapType values instead of adding values inside main() function.
UPDATE: with C++11 onwards you can…
…or similar, where each pair of values – e.g.
{1, 5}– encodes a key –1– and a mapped-to value –5. The same works forunordered_map(a hash table version) too.Using just the C++03 Standard routines, consider: