I’m doing a C++ code that compares various float scores whilst overloading the “>” operator, but when I try to run my code the following error appears:
No operator “>” matches these operands C/C++(349)
This is my code-
cout << endl;
float maxNum = arch[0].get_publicScore();
while(auto i = arch.begin() != arch.end()+1){
if(maxNum > arch[i] ){
i++;
} else {
i++;
}
}
I’ve tried changing the type of overloaded operator (it is a bool) to that of float so it matches with the type of value that I’m comparing, but that didnt work and it just crashed my program.
New contributor
Hannia Escamilla Pérez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1