how and when do I use stl containers? |
Well, there are many good tutorials online about how to use containers. And as for when to use containers; well it totally depends on the requirement. For example,
1. if you want a key and value pair, like domain name and email address, where domain name is the key (it should be unique) and email address is the value (no need to be unique), then use map.
2. If you don't want to specify the size of the array and want a dynamic array then use vectors.
3. If you want a double linked list, i.e. flexibility to insert and delete elements from the middle or anywhere then use list.
4. If you want the functionality to add and delete elements from the front and back then use deque.
Other than that, I don't know if you know about this, but there is this excellent book called as Effective STL by Scott Meyers. In that he has discussed all about when to use which container.
Hope this helps !
Edit: Edited information clarified by @kempofighter