standard template libraries

I need to know how with STL I can use associative arrays, please provide code examples.
LVL 11
BuffonAsked:
Who is Participating?
 
Jaime OlivaresSoftware ArchitectCommented:
>so in declaration first "string" represents key or value?
Yes, first argument is the key
0
 
Jaime OlivaresSoftware ArchitectCommented:
You have to use STL map object. Have a look to a previous discussion:
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20566432.html
0
 
BuffonAuthor Commented:
I saw this declaration:

typedef map<string,string> line;


as I understand it, it declares something like hashtable (value + key), so in declaration first "string" represents key or value?
0
 
Jaime OlivaresSoftware ArchitectCommented:
>as I understand it, it declares something like hashtable (value + key), so in declaration first "string"
>represents key or value?
No, there is an non-standard hash_map<> collection class in some STL implementations.
Map usually have some internal implementation of tree (binary, balanced, etc....) but there is no a rule about this. Anyway, this is transparent to the user.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.