Whats the difference?
I want to be able to see if an element is in a HashMap and I just found out that if I do h[element], it will return the default element if it is not found, and not null. How would I use the iterator find method to see if the element is there?
Thanks
Assuming you’re talking about STL and not some 3rd party library…
m[key]doesn’t just return the default object if key isn’t in the map. It will create a new element in the map with that key and a default-constructed object as value.You could use this:
Or if you don’t need to get the object (you just want to know if it exists):