rect(t/τ)圖像 RectF,Rect和PointF,Point類(lèi)的區(qū)別?
RectF,Rect和PointF,Point類(lèi)的區(qū)別?1. 精度不同。Rect使用int類(lèi)型作為值,rectf使用float類(lèi)型作為值。2這兩種類(lèi)型提供的方法并不完全相同。Rect:equals(o
RectF,Rect和PointF,Point類(lèi)的區(qū)別?
1. 精度不同。Rect使用int類(lèi)型作為值,rectf使用float類(lèi)型作為值。2這兩種類(lèi)型提供的方法并不完全相同。Rect:equals(object obj)(由于某些原因,它是equals本身的實(shí)現(xiàn))exactcenter x()exactcenter y()flattentostring()toshortstring()unflattenfromstring(string STR)rectf:round(Rect)dst)roundOut(Rect dst)set(Rect src)
c 程序設(shè)計(jì),設(shè)計(jì)一個(gè)矩形類(lèi)(rect)?
#include
使用命名空間std
class Rect
{
public:
Rect(int widthint length):width(width),length(length){}
int Area()
{
return length*width
}
int Perimeter()
{
return 2*(length width)
}
friend int add(rect&r1,rect&r2)
private:
int length
int width
}
int add(rect&r1,rect&r2)
{
return R1。區(qū)域()R2。Area()
}
int main()
{
rect1(2,4),rect2(4,6)
cout
cout
cout
cout
return 0
}
運(yùn)行結(jié)果
rect1的面積是8
rect1的周長(zhǎng)是12
rect2的面積是24
rect2的周長(zhǎng)是20
rect1和rect2的面積之和是32
按要繼續(xù)嗎