Re: CMap in CMap
Giovanni Dicanio a ?crit :
I think the problem is that CMap derives from CObject, and CObject
declares *private* copy constructor and operator=.
In fact, if you go to the CObject definition in <afx.h> MFC header file
(at least in VS2008) you can read:
CObject(const CObject& objectSrc); // no implementation
void operator=(const CObject& objectSrc); // no implementation
So, CMap doesn't offer a copy semantic "out of the box".
I would suggest you to use STL std::map container, which is designed in
a way to implement copy semantic out-of-the-box.
In particular, your CMap's:
CMap <int, int, CIAMMetaDataAttribute,
CMap <int, int, int, int> alternateValue;
could be substitued by the following std::map's:
std::map< int, CIAMMetaDataAttribute > EvtAttributes;
std::map< int, int, > alternateValue;
Note that std::map does not have the (IMHO) confusing ARG_KEY and
std::map just has the Key and Type template arguments (in its basic form):
map Class (Standard C++ Library)
thanks for the tip.
In the meantime, I managed to solve my problem by declaring a pointer to
the second CMap instead of the CMap itself.
******* IAMMetaDataAttribute.h **********
CMap <int, int, int, int> *alternateValue;
So I guessed I could get out with it this way... but your post about the
std::map object puzzled me ;)
Could you tell me more about this std::map thing? Is it more efficient
than CMap? It seems to be less convenient to manipulate, isn't it?
Thanks again for your help.