The following code works when I keep the class outside of main(), but if I define the class in main(), I get the error: error: no matching function for call to ‘sort(main()::student [10], main()::student*)’ Why is this?
Code:
#include <iostream>
#include <string>
#include <algorithm>
class student
{
public:
std::string name;
int grade;
bool operator<(const frequency& rhs) const
{
return grade < rhs.grade;
}
};
int main()
{
student student_array[10];
// snip assignment of names and grades to students here
std::sort(student_array, student_array + 10);
return 0;
}