Here's your problem:
struct ShapePointPair {
Shape shape;
Point location;
};
You are storing a Shape
. You should be storing a Shape *
, or a shared_ptr
or something. But not a Shape
; C++ is not Java.
When you assign a Rect
to the Shape
, only the Shape
part is being copied (this is object slicing).