You could use operator overloading to do this -- like this:
inline bool operator< (const A& lhs, const B& rhs)
{
/* do actual comparison */
}
see this question and answer
What are the basic rules and idioms for operator overloading?
You could also use the following pattern with an interface :
interface ExtractDate<T>
{
decimal getDate(integer which);
}
Class A : ExtractDate<A>
{
decimal getDate(integer which)
{
switch (which)
{
case 1 : return this.Jan; break;
case 2 : return this.Feb; break;
case 3 : return this.Mar; break;
}
}
decimal Jan; decimal Feb; decimal Mar;
}
Class B : ExtractDate<B>
{
decimal getDate(integer which)
{
switch (which)
{
case 1 : return this.Jan; break;
case 2 : return this.Feb; break;
case 3 : return this.Mar; break;
}
}
decimal Jan; decimal Feb; decimal Mar;
}
Then you can say
if(A.getDate(1) > B.getDate(1))
{
return false;
}
//etc
If it was me this seems like a lot of work -- I myself would make a object called DateInfo and have both objects implement that object (it is the same in both object) and then compare objects of the same type -- which is much easier.