Select underlying objects
<p>Greetings!</p>

<p>I've made a program that lets you draw shapes. All shapes are contained in a vector. What I need help with is; when several shapes are stacked on top of each other, I want to cycle through them, top to bottom, if the user clicks repeatedly. I'm thinking something along the lines of:</p>

<ol>
<li>Store every object under the mouse location where the user clicked in some sort of container</li>
<li>Keep track of which object was first in queue, and should be last (?) after the next click</li>
<li>Repeat step two until the user clicks somewhere that results in a different queue</li>
</ol>

<p>This is more of a general programming question, rather than just C++, but any help would be greatly appreciated, and if that answer also provides a pretty solution in C++, all the better!</p>
