in case of single map, to see whether a key exists or not mapname.count(keytofind) is used
Code:map<int,bool>rb;
map<int,bool>::iterator rb_it;
rb.insert(make_pair(5,true));
rb.insert(make_pair(7,false));
rb.insert(make_pair(3,true));
int numtofind=7;
if(rb.count(numtofind))
{
rb_it=rb.find(numtofind);
cout<<"\n First= "<<(*rb_it).first<< " Second= "<< (*rb_it).second ;
}
else
{
cout<<"\n The key " << numtofind <<" does not exist in map" ;
}
but in case of map of maps, how a key has to be find ??
how to see whether a particular key exists or not??Code:map<int,map<int,map<int, bool> > >r;
r[3][4][3]=true;
r[3][2][3]=true;
r[3][3][3]=true;