I am trying to make a member function for my class that lets the user input all of the values for the object's variables. When I try to use the constructor inside this function, it does not assign anything new to the variables that were already initialized when the object itself was created. Is there a correct way to do this?
You cannot call constructors directly. If you do, you just create a new object (not alter the current one). Just assign the member fields manually one by one.
Why do you cin to local variables? Why not cin to the data members directly?
eg: Instead of cout << "Enter department: "; cin >> a_department;
then trying to copy a_department to department
just make the assignment: cout << "Enter department: "; cin >> department; and likewise for the other data members?
What am I missing here?
Sometimes I write a function that mirrors the constructor so I can conveniently assign the data member values. Two cases where this is useful:
1) An array of objects was allocated using the default constructor.
2) An objects values are to be re-assigned.