// 25_25-10.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <windows.h>

using namespace std;

class Byte2 {
private:
	char c1, c2;
public:
	Byte2(int n = 0) { c1 = (n & 0xff00)/256; c2 = n & 0xff; }
	Byte2(char a, char b) { c1 = a; c2 = b; }
	operator int() { return c1*256 + c2; }	// 変換関数宣言
	void disp() { cout << "c1=" << c1 << " c2=" << c2 << '\n'; }
};

void func(Byte2 x)
{
	x.disp();
}

int _tmain(int argc, _TCHAR* argv[])
{
	Byte2 b1('A', 'B');	// 標準利用
	Byte2 b2 = 0x4344;	// Byte2←int変換
	int idt;

	b1.disp();
	b2.disp();

	b2 = 0x4546;
	b2.disp();

	func(0x4748);

	idt = b1;
	cout << hex << idt << '\n';

	idt = 0x1000 + b1;
	cout << hex << idt << '\n';

	MessageBox(NULL, _T("Check Console Window"), L"MessageBox", MB_OK);

	return 0;
}

