
please wait
#include <iostream> #include <string> #include <vector> using namespace std; class Employee_Record { int id; string department; string name; int salary; public: Employee_Record(): id(0), department(""), name(""), salary(0) { } Employee_Record(int new_id, string new_department, string new_name, int new_salary): id(new_id), department(new_department), name(new_name), salary(new_salary) { } int get_id() { return id; } string get_department() { return department; } string get_name() { return name; } int get_salary() { return salary; } void set_department(string new_department) { department = new_department; } void set_name(string new_name) { name = new_name; } void set_salary(int new_salary) { salary = new_salary; } void selection_sort(vector<Employee_Record> employees) { int i,j; for (i = 0; i < employees.size()-1; i++) { for (j = i+1; j < employees.size(); j++) { if (employees[i].salary < employees[j].salary) swap(employees[i], employees[j]) ; } } } void display_record(vector<Employee_Record> employees, int j) { for( j = 0; j < employees.size(); j++ ) { cout << employees[j].get_id() << "\t" << employees[j].get_department() << "\t" << employees[j].get_name() << "\t" << "$" << employees[j].get_salary() << endl; } } }; int main() { vector<Employee_Record> employees; Employee_Record act; int id; string department; string name; int salary; int j; cout << "Please enter id, department, name and salary. Use Ctrl+D to exit." << endl; cin >> id >> department >> name >> salary; while (!cin.eof()) { employees.push_back(Employee_Record(id, department, name, salary)); cin >> id >> department >> name >> salary; } (67) act.selection_sort(); (68) act.display_record(); return 0; } |
void selection_sort(vector<Employee_Record> employees)
, however you aren't passing in anything when calling it in main.