#include <condefs.h>
#include <map>
using namespace std;
class fred
{
public:
fred(int a) : i(a) {}
bool operator<(const fred &f) { return i < f.i; } // this will not work — error E2093
//friend bool operator<(const fred &f1, const fred &f2); // this will work
private:
int i;
};
/*
bool operator<(const fred &f1, const fred &f2)
{
return f1.i < f2.i;
}
*/
#pragma argsused
int main(int argc, char* argv[])
{
map mymap;
mymap[fred(0)] = 0;
return 0;
}
|