// 6_6-8.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <windows.h>

using namespace std;

string ssg = "global";

int _tmain(int argc, _TCHAR* argv[])
{
	/* 文スコープ */
	int n = 100;
	cout << n << '\n';	// 100
	for (int n = 1 ; n <= 3 ; n++) {
		cout << n << '\n';	// 1 2 3
	}
	cout << n << "\n\n";

	/* ブロックとスコープ */
	int a = 100;
	cout << a << '\n';	// 100
	for (int i = 1 ; i <= 1 ; i++) {
		int a = 200;
		cout << a << '\n';	// 200
	}
	cout << a << '\n';	// 100
	{
		int a = 300;
		int b = 400;
		cout << a << '\n';	// 300
		cout << b << '\n';	// 400
	}
	cout << a << "\n\n";	// 100
	//cout << b << '\n';	// 変数bは利用できない

	/* ローカル変数の優先とスコープ解決演算子 */
	//string ssl = "local";
	//cout << ssl << '\n';
	//cout << ::ssg << '\n';

	MessageBox(NULL, _T("Check Console Window"), L"MessageBox", MB_OK);

	return 0;
}
