PDA

View Full Version : [SOLVED] Using pointers as keys in C++ map



bluedalmatian
October 19th, 2007, 10:51 AM
If I declare a C++ map which uses pointers to an object as keys,

std::map<MyObject*,int>


when I search for a particular key, am I right in thinking it will match if the pointer points to the same memory address?

Thanks

CptPicard
October 19th, 2007, 11:11 AM
Yep, that's correct... it will match with the same pointer value, that is, the same memory location...

Zdravko
October 19th, 2007, 02:07 PM
Yes, but you would like to define several comparison operators for MyObject*?