Push_back for Vector in Vector
Jun 28, 2010 at 1:22am UTC
I have a class defined as
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
class Employee
{
public :
//need constructor
void processTimeCard(Employee);
void processAddTimeCard(time24, time24);
void processDeleteTimeCard(time24, time24);
// void erase( vector<Employee> &, int );
string getfName();
string getlName();
string getSSN();
double getPayRate();
bool operator <(Employee&);
bool operator ==(Employee&);
friend istream& operator >>(istream&, Employee&);
friend ostream& operator <<(ostream&, Employee&);
private :
string ssn;
string fName;
string lName;
vector<time24> pIn;
vector<time24> pOut;
double payRate;
};
In my main program I need to update the pIn and pOut vectors using push_back
but I dont have the right syntax. It is in this line
staff[found].pIn.push_back(tempTimeIn);
1 2 3 4 5 6 7 8 9 10 11 12 13
if (recType == "T" )
{
weeklyFile >> ssnIn;
found=seqSearch( staff, 0,staff.size(), ssnIn);
if (found< staff.size()) //Record is in vector and can update timecards
{
weeklyFile >> tempTimeIn >> tempTimeOut;
staff[found].pIn.push_back(tempTimeIn);
staff[found].pOut.push_back(tempTimeOut);
}
else
cout << "Could not update employee #" <<ssnIn << " - NOT FOUND" <<endl;
Last edited on Jun 28, 2010 at 1:25am UTC
Jun 28, 2010 at 4:44am UTC
Since you made pIn/pOut private members, you can't access them directly. It is up to you to make public functions that let you add/remove times from those vectors.
Topic archived. No new replies allowed.