Hi,
In below function i am not able to figure out why predicate function cmp_str can't be used with for_each algoritham while using this algoritham with map.
#include <iostream>
#include <map>
#include <utility>
using namespace std;
struct cmp_str
{
bool operator()(string a, string b)
{
return a.compare(b)<0;
}
};
int main()
{
map<string, int > Employees;
// Examples of assigning Map container contents
// 1) Assignment using array index notation
Employees["Mike C."] = 5234;
Employees["Charlie M."] = 3374;
// 2) Assignment using member function insert() and STL pair
Employees.insert(std::pair<string ,int>("David D.",1923));
// 3) Assignment using member function insert() and "value_type()"
Employees.insert(map<string,int>::value_type("John A.",7582));
// 4) Assignment using member function insert() and "make_pair()"
Employees.insert(std::make_pair("Peter Q.",5328));
cout << "Map size: " << Employees.size() << endl;
for_each(Employees.begin(); Empployees.end(); cmp_str);
std::cout << '\n';
//cout << (*ii).first << ": " << (*ii).second << endl;
return 1;
}