다음을 통해 공유


CPoint::operator +

Use this operator to offset CPoint by a CPoint or CSize object, or to offset a CRect by a CPoint.

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

Parameters

  • size
    Contains a SIZE structure or CSize object.

  • point
    Contains a POINT structure or CPoint object.

  • lpRect
    Contains a pointer to a RECT structure or CRect object.

Return Value

A CPoint that is offset by a size, a CPoint that is offset by a point, or a CRect offset by a point.

Remarks

For example, using one of the first two overloads to offset the point CPoint(25, -19) by a point CPoint(15, 5) or size CSize(15, 5) returns the value CPoint(40, -14).

Adding a rectangle to a point returns the rectangle after being offset by the x and y values specified in the point. For example, using the last overload to offset a rectangle CRect(125, 219, 325, 419) by a point CPoint(25, -19) returns CRect(150, 200, 350, 400).

Example

CPoint   ptStart(100, 100);
CSize   szOffset(35, 35);
CPoint   ptEnd;

ptEnd = ptStart + szOffset;

CPoint   ptResult(135, 135);

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);   

Requirements

Header: atltypes.h

See Also

Reference

CPoint Class

Hierarchy Chart

CPoint::operator -=

CPoint::operator -

CPoint::operator +=

CSize::operator +

CRect::operator +

CPoint::Offset

CRect::OffsetRect