No Matching Function Error...

Jan 31, 2013 at 4:19am
Hello, below is my program and the error messages i have been receiving. I have tried many things but cannot get my functions to be called and compiled correctly.


//////////////////////////////////////////
#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;
}


////////////////////////////////////////////

hw2.cpp: In function ‘int main()’:
hw2.cpp:67: error: no matching function for call to ‘Employee_Record::selection_sort()’
hw2.cpp:30: note: candidates are: void Employee_Record::selection_sort(std::vector<Employee_Record, std::allocator<Employee_Record> >)
hw2.cpp:68: error: no matching function for call to ‘Employee_Record::display_record()’
hw2.cpp:42: note: candidates are: void Employee_Record::display_record(std::vector<Employee_Record, std::allocator<Employee_Record> >, int)

////////////////////////////////////////////////
Jan 31, 2013 at 4:53am
The selection_sort function takes in a vector as you currently have it defined in your class. void selection_sort(vector<Employee_Record> employees) , however you aren't passing in anything when calling it in main.

display_record takes a vector and an integer but again you aren't passing anything to it.
Topic archived. No new replies allowed.