CMap and its key types
-
Hi everybody, here's a newbie one for y'all: I was hoping that I'd be able to create an instance of CMap using very simplistic keys with something like:
CMap< int, int&, CMyClass, CMyClass& > m_myMap;
But I get a "'operator =' function is unavailable" error from the compiler. Is this because I have to use keys that are objects of a class, or what? Best regards, Håkan Olsson ------------------------------------ Håkan Olsson, M. Sc. Technical Project Manager Airborne Hydrography AB, Sweden http://www.airbornehydro.com NOTE: All standpoints, opinions, suggestions etc in the above stands for me and me alone and are not in any way affiliated with or endorsed by Airborne Hydrography AB. -
Hi everybody, here's a newbie one for y'all: I was hoping that I'd be able to create an instance of CMap using very simplistic keys with something like:
CMap< int, int&, CMyClass, CMyClass& > m_myMap;
But I get a "'operator =' function is unavailable" error from the compiler. Is this because I have to use keys that are objects of a class, or what? Best regards, Håkan Olsson ------------------------------------ Håkan Olsson, M. Sc. Technical Project Manager Airborne Hydrography AB, Sweden http://www.airbornehydro.com NOTE: All standpoints, opinions, suggestions etc in the above stands for me and me alone and are not in any way affiliated with or endorsed by Airborne Hydrography AB.It is saying that you need to implement an
operator =
within CMyClass.CMyClass& operator =(const CMyClass& right)
{
// Do the copy of data
// e.g. m_Data = right.m_Data;return *this;
}Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain) -
It is saying that you need to implement an
operator =
within CMyClass.CMyClass& operator =(const CMyClass& right)
{
// Do the copy of data
// e.g. m_Data = right.m_Data;return *this;
}Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)UHh... OK. I thought that the "= not defined" thing was about CMap member functions not being able to compare keys rather than the objects...? Anyway, thanks I'll try that! ------------------------------------ Håkan Olsson, M. Sc. Technical Project Manager Airborne Hydrography AB, Sweden http://www.airbornehydro.com NOTE: All standpoints, opinions, suggestions etc in the above stands for me and me alone and are not in any way affiliated with or endorsed by Airborne Hydrography AB.
-
UHh... OK. I thought that the "= not defined" thing was about CMap member functions not being able to compare keys rather than the objects...? Anyway, thanks I'll try that! ------------------------------------ Håkan Olsson, M. Sc. Technical Project Manager Airborne Hydrography AB, Sweden http://www.airbornehydro.com NOTE: All standpoints, opinions, suggestions etc in the above stands for me and me alone and are not in any way affiliated with or endorsed by Airborne Hydrography AB.
If it was complaining about a compare method it would be "==" not "=". Mike