I am working on an exercise on C++ which demands to simulate a service queue and it asks to do it with a round,one dimension array.So it demands, when a customer comes to insert in the queue his name, the number of his card and the arrival time in the queue.
So my first question is how can I enter all these elements in one position of the array?(I don’t know if it is called cell of array or position,English is not my native) Each customer will have to occupy only one position of the array and I have to insert all of his info in one position. I already know the conditions on how to insert or extract an element from a round queue I just don’t know how to do it for lots of them.
Secondly it asks to print how much time the customer has to wait in queue depending on how much people are waiting before him (it doesn’t have to be too precise though).
For the first question: Could you create a class or struct representing the collection of data, and put the entire struct into your container?
(Edit: Customer is now a class, has a constructor; added example of instantiation)
You’ll want to clean this up a little, but something like:
For the second question; if you don’t need to persist the time, and only need to work with differences, one solution is to use clock. Just don’t forget to divide by CLOCKS_PER_SECOND once you take your time difference (in ticks) and need to convert to seconds.