In general terms the < operator has a left hand side and a right hand side. You need to overload the operator for all possible combinations you want to use it in. That is,if A and B are different classes then A < B is different than B < A to the compiler. You can define what < means in any way you wish, but following traditional guidelines is recommended else you end up causing more confusion than it's worth. Here's a simple example of a straightforward overloading process for < using two simple classes.
Code:
struct A
{
int Adata;
bool operator < (A &);
bool operator < (B &);
};
struct B
{
int Bdata;
bool operator < (B &);
bool operator < (A &);
};
bool operator < (A & rhs)
{
Adata < rhs.Adata ? return true : return false;
}
bool operator < (B & rhs)
{
Adata < rhs.Bdata ? return true : return false;
}
bool operator < (B & rhs)
{
Bdata < rhs.Bdata ? return true : return false;
}
bool operator < (A & rhs)
{
Bdata < rhs.Adata ? return true : return false;
}