The map container and its usage

Hopefully I will not need to display the code since it is lengthy. I need some clarification on how maps utiize the copy constructors and assignment operators of the objects they are going to insert. I have a handle class which manages the pointers to a number of what I call 'datamover' objects. The datamover object is an abstract class and is a part of a network backup simulator program I am designing. It seems that when I attempt compile the program using the actual handle like so:

std::map<const string&, h_DM> routingtable;

The compiler complains that it could not find a suitable assignment operator and mentions my overloaded member assignment operator for the object as a candidate. If I change the code to have the map use pointers to the handles, it works:

std::map<const string&, h_DM*>

However, this creates a problem since the pointer may become invalid if it point to a temporary object that has been destroyed. Any ideas? Or do I need to list the code.

Thanks.

multimap<const string> routingTable;
multimap<const string> iterator:: routingTableIterator;

an Iterator works the same as a pointer, for all intensive purposes, it is a pointer.


see here for an example of usage:
http://www.cplusplus.com/forum/general/1099/


Topic archived. No new replies allowed.