I need to write code that defines a struct, an array that can hold 20 occurrences of the struct and a print function.
Read in data
display
sort by name using selection sort
display.
I got up to the first display down then added selection sort to sort
by name and got the error code
Error C2676 binary '>': 'person_info' does not define this operator or a conversion to a type acceptable to the predefined operator
Here is my lines 58, 59, and 60 the > on line 59 is the issue at the moment
for (x = start + 1; x < MAX_PERSON; x++)
if (per_arr[smallest] > per_arr[x])
smallest = x;
Thanks for any help
#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
using namespace std;
const int MAX_PERSON = 20;
struct person_info
{
string name;
int age;
float iq;
};
void print(person_info[], int num_pers);
void sel_sort(person_info per_arr[], int start, int MAX_PERSON);
void swap(int&a, int&b);
int main()
{
ifstream in_file;
person_info rec_arr[MAX_PERSON];
int num_ele = 0, smallest, temp;
in_file.open("data.txt");
Either you provide an operator>(const person_info &pi) const in your class person_info or you use the member variable(s) directly that should be used for the comparison.