Original Post
I have two classes, Surface and Brush. The idea is that Surface provides a drawing surface (and handles all the system resources) and Brush does all the drawing on that surface. The way I want to do it is like so. Surface surf(500, 400); // Create a surface of size 500x400 Brush brush(surf); // Create a brush for the surface brush.draw_line(0, 0, 100, 100); // Draw a line from (0, 0) to (100, 100) I have this working quite nicely, but my concern here is that if we create a Brush somewhere and then the Surface gets destroyed, then we have a Brush that points to a Surface that no longer exists. I have two solutions for this. 1) Keep a running list of surfaces that still exist. Then the Brush can check if the surface it points to exists anymore. (This is how I'm doing it now). 2) Create a connection between the Brush and Surface. The Surface keeps track of which Brushes are assigned to it, and alerts them when it gets destroyed. (I was doing this, but switched to (1) after a while because it's simpler). What I'm wondering is which way is better or if there's a better method beyond these two. Connections betweens objects always seem messy in my opinion, so I'm leaning towards (1), but I'm open to other ideas. Thanks.