Am I making this function correctly?

I need the function ShiftLeft to move to the left. Kind of stuck

void Hostess::PlaceArrivalInQueue(int arrivals){
if(queue_size<15 && arrivals!=0){
queue[queue_size] = arrivals;
queue_size++;
}
}

/*
This function is called when a party from the head of the queue is being seated.
This means that it must be removed from the head of the queue, and all other parties
must move one position to the left
*/
void Hostess::ShiftLeft(queue[], int queue_size){
// FILL THIS FUNCTION//
int temp = queue[0],i;
for(i=0; i<queue_size-1;i++);
queue[i]=temp;
looks wrong to me
why -1 on size, normal loops do 0 to < size?
why assign all the values tmp?
why is there a ; on the end of the for loop? Do you know what this does (its usually a mistake).

what is the point of temp?
Last edited on
If the queue head is position 0 - which is to be removed, then something like (not tried):

1
2
3
4
5
6
void Hostess::ShiftLeft() {
    for(int i =1 ; i < queue_size; ++i)
        queue[i - 1] = queue[i];

    --queue_size;
}

Topic archived. No new replies allowed.