[英]rect in c or c++ language
在C語言中是否有一個名為rect的類型或者在C ++語言中有一個類Rect。
寫
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;
或類似的東西。 這很簡單。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.