No Constructor matches argument list.
May 1, 2013 at 4:32pm UTC
These are the two errors I get...
Error 1 error C2664: 'ProductionWorker::ProductionWorker(std::string,int,std::string,std::string,double)' : cannot convert parameter 4 from 'int' to 'std::string' c:\users\fred steinman\documents\visual studio 2010\projects\employee and productionworker\employee and productionworker\employeeproductionworker.cpp 14
2 IntelliSense: no instance of constructor "ProductionWorker::ProductionWorker" matches the argument list c:\users\fred steinman\documents\visual studio 2010\projects\employee and productionworker\employee and productionworker\employeeproductionworker.cpp 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <string>
using namespace std;
class Employee
{
private :
string employeeName;
int employeeNumber;
string hireDate;
public :
Employee (string eName, int eNumber, string hDate)
{
employeeName = eName;
employeeNumber = eNumber;
hireDate = hDate;
}
void setEmployeeName (string eName)
{
employeeName = eName;
}
void setEmployeeNumber (int eNumber)
{
employeeNumber = eNumber;
}
void setHireDate (string hDate)
{
hireDate = hDate;
}
string getEmployeeName()
{
return employeeName;
}
int getEmployeeNumber()
{
return employeeNumber;
}
string getHireDate()
{
return hireDate;
}
};
#endif
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#ifndef PRODUCTIONWORKER_H
#define PRODUCTIONWORKER_H
#include "Employee.h"
#include <string>
class ProductionWorker : public Employee
{
private :
string eShift;
double payRate;
public :
ProductionWorker (string eName, int eNumber, string hDate, string empShift,
double empPayRate) : Employee(eName, eNumber, hDate)
{
eShift = empShift;
payRate = empPayRate;
}
void setShift(string empShift)
{
eShift = empShift;
}
void setPayRate(double empPayRate)
{
payRate = empPayRate;
}
string getShift()
{
return eShift;
}
double getPayRate()
{
return payRate;
}
};
#endif
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#include <iostream>
#include <string>
#include <iomanip>
#include "ProductionWorker.h"
using namespace std;
char again;
int main()
{
do
{
ProductionWorker info("John Doe" , 123456, "9/28/2010" , 2, 20.00);
cout << "\n\nInformation" << endl;
cout << "-------------" << endl;
cout << "Employee Name: " << info.getEmployeeName() << endl;
cout << "Employee Number: " << info.getEmployeeNumber() << endl;
cout << "Hire Date: " << info.getHireDate() << endl;
cout << "Shift: " << info.getShift() << endl;
cout << "Pay Rate: $" << setprecision(2) << fixed << info.getPayRate() << "/Hour" << endl << endl;
cout << "Do you want to run this program again? Y/N: " ;
cin >> again;
} while (again == 'y' || again == 'Y' );
return 0;
}
I get a red line under the John Doe part.
May 1, 2013 at 4:45pm UTC
1 2
ProductionWorker (string eName, int eNumber, string hDate, string empShift, double empPayRate)
ProductionWorker info("John Doe" , 123456, "9/28/2010" , 2 , 20.00);
Topic archived. No new replies allowed.