I am very new to c++ and would like to know if it is possible to do something like this:
Rectangle rect(Point(0, 0), 10, 10); // doesn't work
The idea is that Rectangle takes a Point object as well as width and height parameters. The constructors look like this:
Rectangle::Rectangle(Point & point, double width, double height) {
this->point = point;
this->width = width;
this->height = height;
};
Point::Point(double x, double y) {
this->x = x;
this->y = y;
};
I can get the desired effect by doing this:
Point point(0, 0);
Rectangle rect(point, 10, 10); // this works
but I think it would be nice if I could instantiate my point directly in the arguments for a new rectangle. If this is possible, please let me know! Thanks!