⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 point.cpp

📁 const是C++中很常用而且很灵活的一种变量,学好使用const对变成很有帮助
💻 CPP
字号:
// Point.cpp: implementation of the Point class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Point.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

const  Point Point::center(0,0);

Point::Point(int _x,int _y):x(_x),y(_y),center_x(0),center_y(0)
{
	x=4;
	y=6;
//	center_x=1;
}

Point::~Point()
{

}
float Point::cal_dist(Point& pt) const
{
	float x=float(this->x-pt.x);
	float y=float(this->y-pt.y);
	return (float)sqrt(x*x+y*y);
}
float Point::cal_dist(Point& pt)
{
	float x=float(this->x-pt.x);
	float y=float(this->y-pt.y);
	return (float)(fabs(x)+fabs(y));
}
void Point::set_x(int newX)
{
	x=newX;
}
void Point::set_y(int newY)
{
	y=newY;
}

int Point::get_x() const
{
	return x;
}

int Point::get_y() const
{
	return y;
}

⌨️ 快捷键说明

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