我需要根据以下不同的标准来比较(>,<,==)
两个类对象
。
class Student
{
int iRollNumber;
int iSection;
int iMarks;
}
- 我想独立地比较iRollNumber、iSection、iMarks。
- 我想合并比较iRollNumber、iSection。
- 我想合并比较iMarks、iSection。
- ..........
目前,我使用GetMethods()
实现此操作,并使用if elseif elseif..
结构进行比较。
这导致代码到处都很混乱!
如果我使用运算符重载
,我必须决定一种比较方式。
请建议一种优雅的编码方式来实现它。
或者
是否可以通过多态调用运算符重载?
RoolNumber
?:P. 应该是RollNumber
:D - Nawaz