// 26_26-3.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"; }
	friend XYpos operator+(XYpos ob1, XYpos ob2);
};

// +演算子の一般関数による多重定義
XYpos operator+(XYpos ob1, XYpos ob2)
{
	return XYpos(ob1.x + ob2.x, ob1.y + ob2.y);
}

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;
}

