S
Steve555
Hi,
Given a simple struct such as:
struct myStruct{
long id;
long length;
long width;
} ;
If I define this to use with std::sort() :
bool operator<(myStruct lhs, myStruct rhs)
{
return lhs.id < rhs.id;
}
How do I then sort by one of the other members such as length and
width?
I thought I could get around it by declaring
typedef myStruct myStructSortHeight;
typedef myStruct myStructSortWidth;
bool operator<(myStructSortHeight lhs, myStructSortHeight rhs)
bool operator<(myStructSortWidth lhs, myStructSortWidth rhs)
but my compiler complains of redefinition.
Thanks
Steve
Given a simple struct such as:
struct myStruct{
long id;
long length;
long width;
} ;
If I define this to use with std::sort() :
bool operator<(myStruct lhs, myStruct rhs)
{
return lhs.id < rhs.id;
}
How do I then sort by one of the other members such as length and
width?
I thought I could get around it by declaring
typedef myStruct myStructSortHeight;
typedef myStruct myStructSortWidth;
bool operator<(myStructSortHeight lhs, myStructSortHeight rhs)
bool operator<(myStructSortWidth lhs, myStructSortWidth rhs)
but my compiler complains of redefinition.
Thanks
Steve