CPoint::operator -

使用前兩個多載其中一項 CPoint減去 CPointCSize 物件。

CSize operator -(
   POINT point 
) const throw( );
CPoint operator -(
   SIZE size 
) const throw( );
CRect operator -(
   const RECT* lpRect 
) const throw( );
CPoint operator -( ) const throw( );

參數

傳回值

CSize 是兩個點之間的差異, CPoint 由大小、 CRect 由負點位移,或 CPoint 相反的位移是負的。

備註

第三個多載由 CPoint負位移 CRect 。最後,使用一元負運算子 CPoint

例如,使用尋找第一個多載的兩個點 CPoint(25, -19) 和 CPoint(15, 5) 之間的差異 CSize(10, -24)傳回。

減去 CSizeCPoint 進行計算和前一個相同,則傳回 CPoint 物件,而不是 CSize 物件。例如,使用尋找第二個多載會在按 CPoint(25, -19) 和大小 CSize(15, 5) 之間的差異 CPoint(10, -24)傳回。

減去矩形從點會在指定的點 xy 值的負數傳回矩形位移。例如,使用最後一個多載位移矩形 CRect(125, 200, 325, 400) 由按 CPoint(25, -19) 傳回 CRect(100, 219, 300, 419)。

使用一元 (Unary) 運算子相反的點。例如,使用建立標準的 CPoint(25, -19) 一元 (Unary) 運算子傳回 CPoint(-25, 19)。

範例

// example for CPoint subtraction
CPoint   ptStart(100, 100);
CSize   szOffset(35, 35);
CPoint   ptEnd;

ptEnd = ptStart - szOffset;

CPoint   ptResult(65, 65);

ASSERT(ptResult == ptEnd);

// also works on SIZE

ptStart = CPoint(100, 100);

SIZE   sz;
sz.cx = 35;
sz.cy = 35;

ptEnd = ptStart - sz;

ASSERT(ptResult == ptEnd);

// example for CPoint unary operator
CPoint   pt(35, 35);
pt = -pt;

CPoint ptNeg(-35, -35);
ASSERT(pt == ptNeg);   

需求

Header: atltypes.h

請參閱

參考

CPoint 類別

階層架構圖

CPoint::operator - =

CPoint::operator +=

CPoint::operator +

CSize::operator -

CRect::operator -

CPoint::Offset

CRect::OffsetRect