C++ STL map.find() not finding my stuff
- by Joe
Hello,
I have constructed a map and loaded it with data. If I iterate over all the elements I see they are all valid. However, the find method doesn't find my item. I'm sure it's something stupid I am doing. Here is snippet:
// definitions
// I am inserting a person class and using the firstname as the key
typedef std::map<char*,Person *> mapType;
mapType _myMap;
mapType::iterator _mapIter;
...
Person *pers = new Person(FirstName, LastName, Address, Phone);
_myMap.insert(make_pair(pers->firstName, pers);
...
...later....
_mapIter = _myMap.find(firstName); // returns map.end
_mapIter = _myMap.find("joe"); // returns map.end
and I have no idea why :(