Posts

Map in STL

Image
MAP in C++ language we have an array to store similar data type and array have the indexing 0-based .but what if we want indexing rather than integer .to solve this kind of problem we have a map which is a container which helps us to store the values in pair. one is key and another is value and orders these pairs is according to keys. Map never contains duplicate key's. EXAMPLE let us suppose you want to store marks of the student then to do this you have to take two arrays's let the name of array is marks[]  and name[] for keep name or mark on the same index in both arrays. it is difficult to deal with the array.we can also do this in easy way with the help of map which will store both name and mark as key and value by using the name of the student we directly get the mark of the student  map is a generic class so you can use any type of primitive or user-defined data type in map. for using map in your program you have to include map header fil