void EmpRecord::addToVector( vector<Employee> newlistVector )
// Temp variables
int id = 0, pay = 0, count = 0;
float tax = 0.0;
string name1, name2;
// Adding a record to the Array
cout << "\nNew employee record.\n"
<< "Please enter the following information as prompted.\n\n";
cout << "How many records will you be adding? ";
cin >> count;
for( int i = 0; i < count; i++ )
id = ( newlistVector.size() + 1 );
cout << "\nEmployee first name: ";
cin >> name1;
cout << "\nEmployee last name: ";
cin >> name2;
cout << "\nEmployee hourly wage: ";
cin >> pay;
cout << "\nEmployee tax rate is 32%";
tax = 0.32;
cout << "\n\n";
// Add the record to the vector
newlistVector.push_back( Employee( id, name1, name2, pay, tax ) );
this code works fine. I can see it fill out the vector in the debugger. However when I run the next command "list" it says the vector is empty
In main, you have a vector listVector that you feed to loadVector.
In processChoice you have a vector listVector. Despite the fact that the vector in processChoice shares a name with the vector in main they are entirely separate and distinct objects. One has absolutely nothing to do with the other, so in processChoice you will not have access to the vector that you loaded with loadVector.
addToVector takes a vector by value as a parameter. This means that in processChoice a copy of the local vector listVector is fed to addToVector. This means that no changes made (to the copy) in addToVector will be reflected in the local-to-processChoice vector that was fed to the function. addToVector should take its parameter by reference: void EmpRecord::addToVector( vector<Employee>& newlistVector )
Likewise, displayRecord need not make a copy of the vector. Passing by const reference would be preferred.