📄 point.cpp
字号:
// ============================================================================
// Point implementation
//
// (c) 2003 Ken Reed
//
// This is free software. You can redistribute it and/or modify it under the
// terms of the GNU General Public License version 2 as published by the Free
// Software Foundation.
// ============================================================================
#include "stdafx.h"
#include "point.h"
#include <math.h>
// ============================================================================
// Construction
// ============================================================================
Point::Point() : x(0), y(0) {}
Point::Point(int xp, int yp) : x(xp), y(yp) {}
// ============================================================================
// Distance to another point
// ============================================================================
int Point::distance_to(Point target)
{
int xo ( (abs) (x - target.x) );
int yo ( (abs) (y - target.y) );
double distance ( sqrt(double ((xo * xo) + (yo * yo))) );
return (int) distance;
}
// ============================================================================
// Convert to POINT (so we can pass our Points to MS POINTS)
// ============================================================================
Point::operator POINT() const
{
POINT p;
p.x = x;
p.y = y;
return p;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -