fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. map<string, int> mpp;
  6. mpp["raj"] = 27;
  7. mpp["hima"] = 31;
  8. mpp["praveer"] = 31;
  9. mpp.insert({"raj", 45});
  10.  
  11. mpp.erase("raj"); // mpp.erase(key)
  12. mpp.erase(mpp.begin()); // mpp.erase(iterator)
  13. mpp.clear(); // entire map is cleaned up
  14.  
  15. auto it = mpp.find("raj"); // points to where raj lies
  16. auto it2 = mpp.find("simran"); // points to end since she does not exists
  17.  
  18. if(mpp.find("raj") == mpp.end()) {
  19. cout << "raj not present";
  20. }
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
raj not present