payyans4u payyans4u - 1 year ago 65
C++ Question

Can two Key Values be same in a Map

I have defined a Map

boost::unordered_map<"std::string,std::string">m_mapABC ;


And I Store values in it Like m_mapABC[strValue1]=strValue2;

And Assume that i store 10 entries to the map.In that case can the same Key Value be used to store 10 different Values..or will it be over written every time...I guess it would.

In that case using
std::pair
would help i guess.

std::map<"std::string, std::pair<"std::string", bool>>myMap2


std::pair
can have 2 Key Values Equal(I guess I am Right)...What will be the bool value in each case,will it be TRUE in the first case and FALSE the second time or vice-versa?.

I also heard about
std::tuple
or
boost::tuple
where a single Key can be used to Store Different Values.

I am not very clear about how to iterate through them...i need help

Answer Source

You may want multimap instead of map.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download