Design patterns in c++

hi.My cousin asked me to help with his assignment .Unfortunately the spec does not clarify. I am suppose to find an object in a queue, remove it and shift other members up in the queue.The problem is when I remove the element, and shift everything up.What happens to the [0] object.

By the way its the observer pattern
Last edited on
The elements aren't supposed to move up, they're supposed to move down and the array size decremented.
Down.But If they move down then what happens to the first element. subscript [0], does it become subscipt[-1] "humour".But seriouslly, now you are loosing me.

Or do you mean that If subscript[5] was removed and only the elements above subscript[5] move downwards.

May you please clarify
It would benefit your cousin much more, if he would do his homework himself. One does learn by doing, and the goal of homeworks is learning.

You do have a set of elements. If you do remove one element, then the size of the set does reduce by one. If the elements of the set are actually stored in a contiguous block of memory, then obviously some of them have to be relocated, because (a) the removed element did leave an empty hole and (b) the block will shrink.

Visualize. Place some rocks into a line. Take one away. What has to be done for the rest in order to remove the gap from the line?
Topic archived. No new replies allowed.