I'm using C++ How to Program 8th Edition and one part of the code says,
Employee::Employee( const string &first, const string &last, const Date &dateOfBirth, const DateOfBirth, const Date &dateOfHire)
: firstName(first), lastName(last), birthDate(dateOfBirth), hireDate(dateOfHire)
{
cout <<"Employee object constructor: " << firstName << ' '<< lastName <<endl;
}
I'm confused. Is this Employee class initializing the 2 Date class objects by copy or by reference? The book says its by a copy constructor, but I see an &ersand before the name of each. Also, if you declare const before a function parameter name, that parameter is unchanged but the original argument passed in may not necessarily be constant right?
Also, you can use constant functions for non constant classes right? The point of declaring a function constant is that that function may not edit any variables declared in the class its in?
Here is the implementation in main()
int main()
{
Date birth(7, 24, 1949);
Date hire (3, 12, 1988);
Employee manager( "Bob", "Blue", birth, hire);
}
birth and hire are objects of class Date
Edit 2: Here is a screenshot of the function defined in the header file. Thanks again. http://tinypic.com/r/qznf6g/8 http://tinypic.com/r/2qdr3tz/8 Thankyou very much!!!! Edit 3: I think I figured it out. So it is using a reference initially to initialize the Date object but then it also uses a copy constructor to assign dateOfBirth to to birthDate in Line 14 right?