how to i check whether the map1 exist or not for some string in
map <string, map1<string, int> > map2

Recommended Answers

All 2 Replies

Make a loop for each object in the map2.
Like this

map<string, map<string, int>>::iterator iter;
for(iter = map2.begin(); iter != map2.end(); ++iter)
{
    try
    {
        if(iter.second.size() == 0)
           std::cout <<"map1 doesn't exist in this record\n";
        else
           std::cout << "map1 exists in this record. It's size is " << iter.second.size() << std::endl;
   }
   catch(Exception e) //if map in this record = NULL
   {
   }      
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.