I can’t see what I’m doing wrong here. I’m not going to show the full creation of my main function because I don’t think it will matter.
My issue has to do with this class that I create:
class employee
{
//create private variables for divider
string firstName;
string lastName;
char gender;
int dependants;
double annualSalary;
static int numEmployees;
public:
Benefit1 benefit;
employee()
{
//create default values for varaibles
firstName = "not given";
lastName = "not given";
gender = 'U';
dependants = 0;
annualSalary = 2000;
}
employee(string first, string last, char gen, int dep, double salary, Benefit1 ben)
{
//allow input
firstName = first;
lastName = last;
gender = gen;
dependants = dep;
annualSalary = salary;
benefit = ben;
}
}
(Yes, Benefit1 was properly called in the class.) My problem comes when I try to instantiate it as employee2:
employee employee2("Mary", "Noia", 'F', "5", 24000.0, benefit1);
For some reason my program will not allow me to put ANYTHING in the first instance where the word “Mary” is. As you can see the first instance is suppose to be string first, so why isn’t it letting use anything?
The problem is with the fifth parameter – it’s expecting an
intand you’r epassing it"5". Try: