I need to have a map like this :
typedef std::map Maptype ;
What is the syntax to insert and searching elements of
You cannot have three elements. The STL map
stores a key-value pair. You need to decide on what you are going to use as a key. Once done, you can probably nest the other two in a separate map and use it as:
typedef std::map > MapType;
In order to insert in a map, use the operator[]
or the insert
member function. You can search for using the find
member function.
MapType m;
// insert
m.insert(std::make_pair(4, std::make_pair(3.2, 'a')));
m[ -4 ] = make_pair(2.4, 'z');
// fnd
MapType::iterator i = m.find(-4);
if (i != m.end()) { // item exists ...
}
Additionally you can look at Boost.Tuple.