Hi, I'm trying to overload the < and > operators to compare two objects but when I try to use them, nothing happens.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Overloaded > operator
bool StudentRecord::operator>(StudentRecord& ref){
cout<<"IN > OP"<<endl;return m_mark > ref.GetMark();
}
// Overloaded < operator
bool StudentRecord::operator<(StudentRecord& ref){
cout<<"IN > OP"<<endl;return m_mark < ref.GetMark();
}
when I compare I use the following code:
for(int i=0;i<m_numRecords;i++){
if(m_ppRecords[i]>highest)
highest = m_ppRecords[i]; // Here I use overload assignment which works
} // how it's suppose to