I am trying to make this queue right now that uses elements in an array to increase the appointment time for a queue. Only problem is I don't really know how to get each individual element from the array to add it to the queue. I thought I could just use the code apptQ.push(apptQ.front + apptList.pop); but that would only work with a stack right? Can anyone give me some pointers? Here is my code, thanks.

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <queue>
#include "d_time24.h"
#include "d_except.h"
using namespace std;

int main()
{
    const int APPTLISTSIZE = 10;
    queue<time24> apptQ;
    int apptList[] = {45, 75, 60, 90, 15, 25, 40, 30, 35, 45};
    time24 t(10,00);    //initial time 10:00 am

    apptQ.push(t);//inserts t as the first appointment in the queue

    return 0;
}

>apptQ.push(apptQ.front + apptList.pop); but that would only work with a stack right?
No, that wouldn't ever work because front is a member function, pop is a member function, and apptList isn't even an object, it's an array.

Assuming time24 has a single argument constructor, you could do something similar to this:

for (int i = 0; i < 10; i++)
  apptQ.push(apptList[i]);

OK, I see what you mean bby the array is not an object and I get the code you sent. But to modify it a little to make it add the element in the array to the last time in the queue and keep doing it for every element in the array until it is used up. So you would just do the same thing practically but use;
for (int i = 0; i < 10; i++)
apptQ.push(apptQ.front + apptList);
The only problem with doing this though is that it is always going to get the front value for the queue (10:00am) which I actually need to be constantly adding it to the last time entered. So after the first time 45 min is added to 10:00am the 75 min should be added to 10:45 and so on.

Oh, I see what you're trying to do. Now it really does matter how time24 is defined. Could you please elaborate on that type? This has a good chance of working if you have a way of extracting the first part of a time24 value:

for (int i = 0; i < 10; i++)
  apptQ.push(time24(apptQ.top().first(), apptList[i]));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.