This is my first shot at using a header file and linking it to other projects, so bare with me, this whole thing is probably full of a ton of issues.. But I cannot make it past this one particular issue, once I do, I will try work out the other things... But right now I keep getting 'string' has no been declared.
Okay.. I fixed the string issue, I think what the problem was is that I didn't have the project set up correctly.. I'm still having issues though, so any further help would be appreciated..
You have defined collectName() to take 2 arguments, and collectSalary() to take 1 argument. How many arguments are you actually passing in when you call those methods?
EDIT: And, now that I look at those function definitions, perhaps you ought to consider why you want those functions to take those arguments, and what you are or aren't doing with them.
Thank you all for the advice. I mixed in the above and I achieved what I was aiming for.. But can anyone explain to me how line 5 in employee.cpp works? I'm assuming : links the class variables with the variables collected in main, but how does that work? Also, I'm confused with how employee& update_from_stdin works and the for loops (lines 24 and 26 in main). If anyone can explain those, or point me to a tutorial/page that might further shed light onto them I'd very much appreciate it..
Initialize class members from constructor arguments by using a member initializer list. This method uses direct initialization, which is more efficient than using assignment operators inside the constructor body. https://msdn.microsoft.com/en-us/library/s16xw1a8.aspx#member_lists
how employee& update_from_stdin works:
the long form of return e = employee( fname, lname, sal ) ; is:
1 2 3 4 5 6 7 8 9 10 11 12
// step 1. create a temporary employee object initialised with fname, lname, sal
employee temporary_object( fname, lname, sal ) ;
// step 2 : assign this temporary object to 'e' (reference to the employee object in the array)
// 'e' gets modified to become a copy of the temporary_object
// in practice, the temporary object is move assigned rather than copy assigned;
// you may want to ignore this nicety for now
e = temporary_object ; // e = std::move(temporary_object) ;
// step 3. return (reference) to 'e' (the object that was passed to the function, and modified in it)
// note: this result is ignored in main () where update_from_stdin(e) is a discarded-value expression
return e ;
for loops (lines 24 and 26 in main):
A range for statement allows you to iterate through a "range" ... All standard containers can be used as a range, as can a std::string, an initializer list, an array, .... http://www.stroustrup.com/C++11FAQ.html#for
Also note the const qualifier on the member functions full_name, salary and display
Declaring a member function with the const keyword specifies that the function is a "read-only" function that does not modify the object for which it is called .... To declare a constant member function, place the const keyword after the closing parenthesis of the argument list. The const keyword is required in both the declaration and the definition. https://msdn.microsoft.com/en-us/library/07x6b05d.aspx