E
Eric Lilja
Hello! Consider this code:
const char ops[] = {'*', '/', '+', '-'};//, '(', ')' };
const int input_prio[] = { 3, 3, 1, 1 };//, 100, 0 };
const int stack_prio[] = { 4, 4, 2, 2 };//, 0, 99 };
bool GetPriority::is_map_initialized = false;
map<char, int> GetPriority::stack_priority_map;
map<char, int> GetPriority::input_priority_map;
void
GetPriority::initialize_maps()
{
for (unsigned int i = 0; i < sizeof(ops) / sizeof(ops[0]); ++i)
{
input_priority_map[ops] = input_prio;
stack_priority_map[ops] = stack_prio;
}
}
What I would like to know if there's a way to initialize my two maps
(they are static data members of the class GetPriority) using the
constructor so I can remove initalize_maps() and the flag I check
before each map use (is_map_initialized)?
- Eric
const char ops[] = {'*', '/', '+', '-'};//, '(', ')' };
const int input_prio[] = { 3, 3, 1, 1 };//, 100, 0 };
const int stack_prio[] = { 4, 4, 2, 2 };//, 0, 99 };
bool GetPriority::is_map_initialized = false;
map<char, int> GetPriority::stack_priority_map;
map<char, int> GetPriority::input_priority_map;
void
GetPriority::initialize_maps()
{
for (unsigned int i = 0; i < sizeof(ops) / sizeof(ops[0]); ++i)
{
input_priority_map[ops] = input_prio;
stack_priority_map[ops] = stack_prio;
}
}
What I would like to know if there's a way to initialize my two maps
(they are static data members of the class GetPriority) using the
constructor so I can remove initalize_maps() and the flag I check
before each map use (is_map_initialized)?
- Eric