Ok I solved that error by instead of declaring and passing to my functions, instead I declared inside each function. I still don't understand why I couldn't declare and pass though... if anyone has an answer for that that would be appreciated.
And so I was able to compile and run, but then didn't get far. I made a very stupid mistake back in the first part of my program, go figure. I made my names characters instead of character arrays, so anytime I would try to type a name, I would get a sec fault, core dump. Now here is my new problem...
csci2>g++ payRoll.cpp EmployeeList.cpp Employee.cpp
Employee.cpp: In member function `void Employee::EmployeeInfo(char*, char*, int, double, int)':
Employee.cpp:16: error: incompatible types in assignment of `char*' to `char[30]'
Employee.cpp:18: error: incompatible types in assignment of `char*' to `char[30]'
14 15 16 17 18 19 20 21 22 23 24
|
void Employee::EmployeeInfo(char *name1, char *name2, int ident, double payRate, int hoursWorked)
{
fName = new char[strlen(name1) +1];
strcpy (fName, name1);
lName = new char[strlen(name2) +1];
strcpy (lName, name2);
id = ident;
rate = payRate;
hours = hoursWorked;
}
|
My fName and lName are declared as char arrays. Is there anyway I can make the new operator return a nonpointer value?
Or if not, how do I need to modify my declaration to fit?
1 2 3 4 5 6 7
|
private:
int id;
char fName[SIZE];
char lName[SIZE];
double wage;
double rate;
int hours;
|