Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
22
Добавлен:
02.05.2014
Размер:
977 б
Скачать
#include "stdafx.h"
#include "dpoint.h"
#include "math.h"

// конструктор по умолчанию
CDPoint::CDPoint(void)
: x(0.0)
, y(0.0)
{
}
// конструктор копирования
CDPoint::CDPoint(const CDPoint& pt)
: x(0.0)
, y(0.0)
{
	x=pt.x;
	y=pt.y;
}
// конструктор с параметрами
CDPoint::CDPoint(double _x, double _y)
{
	x=_x;
	y=_y;
}
// Деструктор
CDPoint::~CDPoint(void)
{
}

CDPoint CDPoint::operator*(double n)
{
	return CDPoint(x*n,y*n);
}
CDPoint& CDPoint::operator=(const CDPoint& pt)
{
	x=pt.x; 
	y=pt.y; 
	return *this;
}
CDPoint CDPoint::operator+(CDPoint& pt)
{
	return CDPoint(x+pt.x,y+pt.y);
}
CDPoint CDPoint::operator-(CDPoint& pt)
{
	return CDPoint(x-pt.x,y-pt.y);
}
void CDPoint::operator+= (CDPoint& pt)
{
	x+=pt.x; 
	y+=pt.y;
}
void CDPoint::operator-= (CDPoint& pt)
{
	x-=pt.x;
	y-=pt.y;
}
double CDPoint::operator!()
{
	return fabs(x)+fabs(y);
}

CPoint CDPoint::Toint()
{
	return CPoint(int(x),int(y));
}
Соседние файлы в папке MOLab1