/*
 * Auto to programma ylopoiei thn klassh EVector, pou anaparista ena Eukleidio Dianysma
 * kai kapoioes prakseis metaksy dianysmantwn.
 * H klassh EVector periexei ton constructor ths klasshs, th synarthsh add
 * pou pros8etei dyo dianysmata, th synarthsh minus pou kanei thn afairesh metaksy
 * dyo dianysmatwn kai th synarthsh norm poy ypologizei thn apostash tou dianysmatos
 * apo thn arxh twn aksonwn. 
 */

#include <iostream>
#include <cmath>

using namespace std;

class EVector
{
	private: 
	double x,y;
  	public:
	/*Constructor*/
   	EVector(double x,double y)
   	{
     		this->x = x;
     		this->y = y;
	}

   	EVector* add (EVector v)
	{
		EVector* ret = new EVector(0,0);

		ret->x=x+v.x;
		ret->y=y+v.y;

		return ret;
 	}

	EVector* minus (EVector v)
	{
		EVector* ret = new EVector(x-v.x, y-v.y);

		return ret;
	}

   	double norm();
};

int main (void)
{
	EVector *v1,*v2,*v3;
   
	v1 = new EVector(1.2,1.5);
	v2 = new EVector(2,3);

	v3=v1->add(*v2);

	cout << "v1 norm: " << v1->norm() <<endl;
	cout << "v2 norm: " << v2->norm() <<endl;
	cout << "v1+v2 norm: " << v3->norm() <<endl;
	cout << "v1-v2 norm: " << (v1->minus(*v2))->norm() <<endl;

	delete v1;
	delete v2;
	delete v3;

	return 0;
}

double EVector::norm()
{
	return sqrt(x*x+y*y);
}
