1. you can not initialize c-style character arrays like you are trying to do in the class constructor. My suggestion is to declare them as c++ string objects. If you can not do that then to initialize the arrays to empty string just set the first byte to 0, like this:
last_name[0] = 0;
line 30: you have to add the parameter names as well as their data types, and declare them asconst because they are unchangeable by the setName function.
void setName(const char* LastName, const char* FirstName); You need to change the other methods in lines 31-34 the same way.
line 40: too many parameters -- see line 30
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
elete: lines 43, 45 and 47 of the code you posted are wrong. C-style character arrays can not be copied like that. You have to call strcpy function to copy them.
tones:
line 33: close, you forgot to make the variables pointers, see the stars here:
Employee(char* last_name = "", char* first_name = "", char* ss_num = "0", double salary = 0, int years_employed = 0);
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
elite: you are still wrong! That does indeed copy the pointers but the class needs its own copy of those strings because the calling function may change the string contents. If you need to use character arrays then declare them as in the original post but in the class constructor you have to call strcpy to duplicate the string so that the calling function can not change the string contents.
My personal preference is to use std::string class instead of character arrays, but the OP may not be able to do that.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343