How to extract the key name in hash_map

S

sam

HI,

I want to know what the key is in a hash_map object.
eg.
myhash["key_name"] = "value";

How can I extract the "key_name" from myhash?

Thanks
Sam
 
G

Ganesh

Use an iterator to map, and then use .first and .second on it to get
key and value.

-Ganesh
 
C

Carlos Martinez Garcia

sam said:
HI,

I want to know what the key is in a hash_map object.
eg.
myhash["key_name"] = "value";

How can I extract the "key_name" from myhash?

Thanks
Sam

I suppose hash_map to behave like map template.
With map objects, when you access objects contained through an iterator
it returns a template object of type Pair.
Pair contains two elements, called first and second.
first is the key, and second is the data associated with that key.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,206
Latest member
EpifaniaMc

Latest Threads

Top