Hi everyone. I'm a reta-I mean a beginner and 98% of my bugs are something really obvious... but I've checked this so much and I don't know what to do. This is my function to create an Employee object, called when the user wants to add a new employee to the system.
void EmployeeList::BuildEmployee (void)
{
int skill, benefit;
string fstname, lstname;
long SSN;
float hours, perCont;
cout << "Enter employee first name" << endl;
getline (cin, fstname);
E2.setFirstName(fstname);
cin.ignore(10, '\n'); // somehow this line allows the next cout to print. I just found it in a sample program and it worked so I didn't question... *hides in shame*
cout << "Enter employee last name" << endl;
getline (cin, lstname);
E2.setLastName(lstname);
cout << endl << fstname << " " << lstname << endl; // just to see if it ACTUALLY HAPPENED just within this function D:<
cout << "Enter social security number" << endl;
cin >> SSN;
E2.setSSN(SSN);
cout << "Enter skill level" << endl;
cin >> skill;
E2.setSkill (skill);
cout << "Enter hours worked" << endl;
cin >> hours;
E2.setHours(hours);
cout << "Enter benefit code" << endl;
cin >> benefit;
E2.setBenefit(benefit);
if (skill == 4)
{
cout << "Enter retirement contribution percent" << endl;
cin >> perCont;
E2.setPercent(perCont);
}
}
So... say I want to hire Franziska Von Karma.
What prints is
Enter employee first name
--> Franziska
Enter employee last name
--> Von Karma
Von Karma
Enter social security number
... etc
So, the first name 'Franziska' is just ... completely NOT read. I know it's not the setters. And... the last name and the rest of it works fine. o_o