You can create a map with operator lines as keys and function objects for the corresponding comparison operations as values.
Map Creation:
std::map<std::string, boost::function<bool(int, int)> > ops;
ops["=="] = std::equal_to<int>();
ops["!="] = std::not_equal_to<int>();
ops[">"] = std::greater<int>();
ops["<"] = std::less<int>();
ops[">="] = std::greater_equal<int>();
ops["<="] = std::less_equal<int>();
Using:
bool resultOfComparison = ops[str](salary[i], 9000);
(see this link for a full working example.)
EDIT:
@sbi , map[key] , . it = map.find(key). map.end(), , it->second. , .