pop function

what are the steps to pop the element from queue in a pop function?

This is my code
http://pastebin.com/gfYWcsfS
Well the basic idea is to copy all of the elements except for the last one into the queue. To do this you might have to create a copy of the array. However, this task would be much easier with an std::vector. You could use the built in pop function, and because it automatically resizes itself, you don't have to have a expandQ method either. Another piece of advice, you might want to put the structure order inside SandwichQueue.

Also, just a piece of advice. Your code will be much easier to follow if you put the implementation of your classes before the main function, or just in a seperate file :)
Last edited on
thank you for your advice
teacher provide this source as it is, so we have to complete those functions

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
//function to pop
Order SandwichQueue::pop()
{
 
 
 
 
}
 
//push an element, make sure it is not full, if it is call expand funciton
void SandwichQueue::push(const Order& sw)
{
   
 
       
}
 
//Double the queue size, copy the values, and reset back and front
void SandwichQueue::expandQ()
{
 
 
 
}



what if I check if it is empty?!!!
I don't understand what you're asking. Just use what I told you to fill the functions in.
Last edited on
Topic archived. No new replies allowed.