I need compare(>,<,==)two class objectbased on the different criteria described below.
class Student
{
int iRollNumber;
int iSection;
int iMarks;
}
- I want to make a comparison with
iRollNumber, iSection, iMarks(independently). - I want to make a comparison with
iRollNumber, iSection(Combined). - I want to make a comparison with
iMarks, iSection(Combined). - ..........
I am currently achieving this with help GetMethods()and comparing them using structure if elseif elseif...
This leads to messy code everywhere!
If I use operator overloading, I have to solve one of the comparison methods.
Please suggest a way to do this with elegant coding.
or
Is it possible to cause operator overload Polymorphically?
source
share