Rectangle(int x, int y, int h, int w);
What does
Rectangle (100,200,50,100)
mean? Are
h
and
w
the coordinates for the bottom right corner or a height and
a width? To avoid errors, we should be more specific about
Rectangle
’s requirements on its arguments:
Rectangle(Point xy, Area hv);
I can now write the clearer and less error-prone
Rectangle(Point(100,200), Area(50,100));
I can also add a second version:
Rectangle(Point top_left, Point bottom_right);
and use either of the following to suit my needs and
preferences:
Rectangle(Point(100,200), Area(50,100));
Rectangle(Point(100,200), Point(150,300));
To be relevant for infrastructure development, simple
user-defined types (such as
Do'stlaringiz bilan baham: |