I am currently working on a grocery store simulation program, which simulates arrival time, how long it takes them to shop, and their departure time for (x) amount of customers by using a clock that starts at 0 and cuts the simulation off at (10080[7*24*60]) for a 7 day a week, 24 hour store.
We are to make a type struct of customer to hold the customers id, arrival time, wait time(the time they wait in line after they finish shopping and before they actually get serviced), and the time it takes for them to start to get in line(s_checkout), and then we put them into a list. Arrival time(atime) and s_checkout are calculated with a random number generator
We find the minimum s_checkout for all the customers in the store at the time, and then once that is the next event to come up, we are to remove that customer(of type cust) from the list and push them into a Queue.
I have everything finished I believe, but the removal of the customer into a queue. What I DO have for it makes sense to me in my head. My list is called custList, and I have tried:
custList.remove(customer); and custList.erase(customer)
Here is the error I keep getting:
Here is the code I have for the section:
If I take out the custList.remove(customer), there is no error when I compile/link. It just doesn't remove the customer from the list.
Any help would be appreciated. Normally I can find the error when they are given, but I'm not really certain what half the stuff in the error is... haha
We are to make a type struct of customer to hold the customers id, arrival time, wait time(the time they wait in line after they finish shopping and before they actually get serviced), and the time it takes for them to start to get in line(s_checkout), and then we put them into a list. Arrival time(atime) and s_checkout are calculated with a random number generator
We find the minimum s_checkout for all the customers in the store at the time, and then once that is the next event to come up, we are to remove that customer(of type cust) from the list and push them into a Queue.
I have everything finished I believe, but the removal of the customer into a queue. What I DO have for it makes sense to me in my head. My list is called custList, and I have tried:
custList.remove(customer); and custList.erase(customer)
Here is the error I keep getting:
Code:
In file included from /usr/include/c++/4.5/list:66:0,
from /home/onyuksel/courses/340/common/340.h:19,
from /home/onyuksel/courses/340/progs/11f/p5/prog5.h:1,
from prog5test.cc:1:
/usr/include/c++/4.5/bits/list.tcc: In member function âvoid std::list<_Tp, _Alloc>::remove(const value_type&) [with _Tp = cust, _Alloc = std::allocator<cust>, value_type = cust]â:
prog5test.cc:82:27: instantiated from here
/usr/include/c++/4.5/bits/list.tcc:196:4: error: no match for âoperator==â in â__first.std::_List_iterator<_Tp>::operator* [with _Tp = cust, _Tp& = cust&]() == __valueâ
Here is the code I have for the section:
Code:
customer = *min_element(custList.begin(), custList.end(), cmp);
if (customer.s_checkout < nextCustArr && customer.s_checkout < departureCust)
{//begin if
custList.remove(customer);
custQ.push(customer); //pushes customer onto Queue
customer = *min_element(custList.begin(), custList.end(), cmp);
if (custQ.size() == 1)
{//begin if
customer = custQ.front();
departureCust = dept_time(clock); //gets the customers departure$
}//end if
clock = customer.s_checkout;
}//end if
If I take out the custList.remove(customer), there is no error when I compile/link. It just doesn't remove the customer from the list.
Any help would be appreciated. Normally I can find the error when they are given, but I'm not really certain what half the stuff in the error is... haha