// 29_29-5.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <cstring>

using namespace std;

// 標準のテンプレート記述
template <typename T> int comp(T d1, T d2)
{
	cout << "a: ";
	if (d1 > d2) {
		return 1;
	}
	if (d1 < d2) {
		return -1;
	}
	return 0;
}

// 特別バージョン1
template<> int comp<char *>(char *s1, char *s2)
{
	cout << "b: ";
	if (strcmp(s1, s2) > 0) {
		return 1;
	}
	if (strcmp(s1, s2) < 0) {
		return -1;
	}
	return 0;
}

// 特別バージョン2
template <> int comp<const char*>(const char *s1, const char *s2)
{
	cout << "c: ";
	if (strcmp(s1, s2) > 0) {
		return 1;
	}
	if (strcmp(s1, s2) < 0) {
		return -1;
	}
	return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
	char ss1[] = "AAA", ss2[] = "BBB";

	cout << comp(10, 20) << '\n';
	cout << comp(20, 10) << '\n';
	cout << comp(33.44, 33.44) << '\n';
	cout << comp(ss1, ss2) << '\n';
	cout << comp("aaa", "bbb") << '\n';

	MessageBox(NULL, _T("Check Console Window"), L"MessageBox", MB_OK);

	return 0;
}

