Is there a type called rect in C or class Rect in C++ language.
No.
These languages generally don't include application-specific APIs and types.
Microsoft's Win32 API includes a type called RECT, and there are probably countless others once you start looking at external API:s.
Write
template<class T>
struct podrect
{
T left;
T top;
T right;
T bottom;
};
template<class T>
struct rect
{
rect() : left(), top(), right(), bottom() {}
rect(T left, T top, T right, T bottom) :
left(left), top(top), right(right), bottom(bottom) {}
template<class Point>
rect(Point p, T width, T height) :
left(p.x), right(p.y), right(p.x + width), bottom(p.y + height) {}
T left;
T top;
T right;
T bottom;
};
typedef rect<int> intrect;
typedef rect<float> floatrect;
or something like this. It's very simple.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With