Suppose I have map
Which of the following method are best to use for insertion?Code:map<string, int> Employees;
1. Assignment using array index notation
2. Assignment using member function insert() and STL pairCode:Employees["Mike C."] = 5234; Employees["Charlie M."] = 3374;
3. Assignment using member function insert() and "value_type()"Code:Employees.insert(std::pair<string,int>("David D.",1923));
4. Assignment using member function insert() and "make_pair()"Code:Employees.insert(map<string,int>::value_type("John A.",7582));
Code:Employees.insert(std::make_pair("Peter Q.",5328));




Reply With Quote