// 26_26-2.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <windows.h>

using namespace std;

class XYpos;
XYpos operator+(XYpos ob1, XYpos ob2);

class XYpos {
private:
	int x, y;
public:
	XYpos(int a = 0, int b = 0) { x = a; y = b; }
	void disp() { cout << "(" << x << "," << y << ")\n"; }
	int getX() { return x; }
	int getY() { return y; }
};

// +演算子の一般関数による多重定義
XYpos operator+(XYpos ob1, XYpos ob2)
{
	return XYpos(ob1.getX() + ob2.getX(), ob1.getY() + ob2.getY());
}

int _tmain(int argc, _TCHAR* argv[])
{
	XYpos d1(100, 200), d2(30, 40), d3;

	d3 = d1 + d2;
	d1.disp();
	d2.disp();
	d3.disp();
	
	MessageBox(NULL, _T("Check Console Window"), L"MessageBox", MB_OK);

	return 0;
}

