Is it possible to have some variable shared between some objects of the same class such that, when the value is changed in one object, it will also change in the other object? Static variables would not work in this case, because there could be 2 objects that all have some related variable and another 2 objects that have a different related variable.
For example, say I have 4 squares that are arranged to make one large square, and the squares coordinates lie in an x,y,z plane. When the 4 squares are together, they would all have a point that lies in the center of the biggest square.
Pretend this square also has a z coordinate. Now, the squares will all share the point that lies in the center. The top left square's bottom right corner, the top right square's bottom left corner, etc., will all have the same (x, y, z) value.
Now what I want, is such that if the z value of one square changes, they will all change without any extra code, like they all point to the same memory location, so they "automatically" update in a sense.
Is something like this possible?