C++: coordinates (x,y) overlapping, classes

Hi everyone!
I would like to know how can I create a set of classes where there is a main big square shape with coordinates (x,y).
And derived rectangular and squared shapes with coordinates that are within the main square shape?

Also how can I create a simple "void" move function to move my classes inside the perimeter of the main square? Thanks.
closed account (48bpfSEw)
a speed sketch:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Square {
  int x1,y1,x2,y2;
};

class Rectangle : public Square {
  int x1_relativ, y1_relativ, x2_relativ, y2_relativ;

  void Draw(void) {
    system.rect (x1+y1_relativ, y1 +y1_relativ, x2+y2_relativ, y2+y2_relativ);
    }

  void Move (int x_delta, int y_delta) {
    x1 += x_delta;
    y1 += y_delta;
    x2 += x_delta;
    y2 += y_delta;
    }
}
can you be more precise?
closed account (48T7M4Gy)
I get the impression you are moving rectangular objects within square objects.
Topic archived. No new replies allowed.