I posted earlier for help with this and someone gave me a good clue and I worked with it but I am still boggled. I have been working on a couple different ways to accomplish this but have come up with nothing right yet. I am close but still need help. I need to be able to take the element one at a time out of an array and add them to a start time and then push them onto the queue. I know how but just can't figure out why it is not working. I thought the last code I made did it but when executed it just kept outputing the same numbers. The appts start at 10:00 am and then add each successive element in the array to the start time for each appt. Here is the code if anyone can help please I could use it. Thanks.
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <queue>
#include "d_time24.h"
#include "d_except.h"
using namespace std;
int main()
{
time24 startTime;
time24 endTime;
const int APPTLISTSIZE = 10;
queue<time24> apptQ;
int apptList[] = {45, 75, 60, 90, 15, 25, 40, 30, 35, 45};
time24 t(10,00);
apptQ.push(t);//inserts t as the first appointment in the queue
/*for (int i = 0; i < 9; i++)
{
startTime = apptQ.front();
endTime = startTime + apptList[ i];
apptQ.push(endTime);
}
*/
for(int i = 0; i < 9; i++)
{
apptQ.push(apptQ.front() + apptList[ i]);
}
while(!apptQ.empty())
{
for( int i = 0; i < 10; i++)
{
cout << "Appt " << i+1 << " Start " << apptQ.front() << " End " << apptQ.front() + apptList[ i] << " Length " << apptList[ i] <<endl;
apptQ.pop();
}
}
return 0;
}
Code tags added. -Narue