7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C++のPointクラス

Posted at

Pointクラス

最近なぜか多用する自作クラス。
なぜか紹介。

class Point
{
public:
	Point() { Point(0, 0); }
	Point(int x, int y) { this->x = x;this->y = y; }
	~Point();

	Point &operator=(Point &point);
	Point &operator+=(Point &point);
	Point &operator-=(Point &point);
	Point &operator*=(Point &point);
	Point &operator/=(Point &point);

	Point operator+(Point point);
	Point operator-(Point point);
	Point operator*(Point point);
	Point operator/(Point point);
	
	bool operator==(Point point);

	int getX() { return x; }
	int getY() { return y; }
	
	int getIndex(int width) { return (y*width+x); }

	static Point GetPoint(int x, int y) { Point point(x, y); return point; }

private:
	int x, y;
};

結構たいへんだった・・・
でも結構便利
ただ、テンプレート使えばよかった・・・
float とか使いたいし・・・

また気が向いたら作ります(殴

7
4
9

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?