N
NewToCPP
I am having problem with key compare in stl map. Below is part of my
code .. could anyone tell me what might be wrong here...
I am using VC++ 6.0
code:
=====
class MyKey
{
public:
unsigned long value;
unsigned long type
bool operator<(const MyKey& right)
{
return ( type< right.type) &&
( value < right.value );
}
};
class MapTest
{
public:
std::map<MyKey, MyClass* > myMap;
MapTest();
~MapTest();
void addElement(MyClass* pClass);
OmciCommonMe* findElement(MyKey key);
};
Error:
-------
c:\program files\microsoft visual studio\vc98\include\functional(86) :
error C2678: binary '<' : no operator defined which takes a left-hand
operand of type 'const class MyKey' (or there is no acceptable
conversion)
c:\program files\microsoft visual
studio\vc98\include\functional(86) : while compiling class-template
member function 'bool __thiscall std::less<class MyKey>:perator
()(const class MyKey &,const class MyKey &) const'
code .. could anyone tell me what might be wrong here...
I am using VC++ 6.0
code:
=====
class MyKey
{
public:
unsigned long value;
unsigned long type
bool operator<(const MyKey& right)
{
return ( type< right.type) &&
( value < right.value );
}
};
class MapTest
{
public:
std::map<MyKey, MyClass* > myMap;
MapTest();
~MapTest();
void addElement(MyClass* pClass);
OmciCommonMe* findElement(MyKey key);
};
Error:
-------
c:\program files\microsoft visual studio\vc98\include\functional(86) :
error C2678: binary '<' : no operator defined which takes a left-hand
operand of type 'const class MyKey' (or there is no acceptable
conversion)
c:\program files\microsoft visual
studio\vc98\include\functional(86) : while compiling class-template
member function 'bool __thiscall std::less<class MyKey>:perator
()(const class MyKey &,const class MyKey &) const'