d-point.h

来自「一些学习c++的例题」· C头文件 代码 · 共 34 行

H
34
字号
#ifndef __POINT_H__
#define __POINT_H__

struct CPoint
{
   int x, y;

   CPoint(const int xx = 0, const int yy = 0) : x(xx), y(yy) {}
   CPoint(const CPoint& p) : x(p.x), y(p.y) {}
   ~CPoint() {}

   CPoint& operator=(const CPoint& p)
   {
      x = p.x;
      y = p.y;
      return *this;
   }

   CPoint& operator+=(const CPoint& p)
   {
      x += p.x;
      y += p.y;
      return *this;
   }

   CPoint& operator*=(const float s)
   {
      float t1 = x * s, t2 = y * s;
      x = int(t1);  y = int(t2);
      return *this;
   }
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?