// 27_27-6.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <windows.h>

using namespace std;

// 基底クラス
class ClsA {
protected:
	int a;
public:
	ClsA(int n = 0) { a = n; }
	int getA() { return a; }
	void disp() { cout << "ClsA a=" << a << '\n'; }
};

// 派生クラス
class ClsB : public ClsA {
private:
	int b;
public:
	ClsB(int n1 = 0, int n2 = 0) : ClsA(n1) { b = n2; }
	int getB() { return b; }
	void disp() { cout << "ClsB a=" << a << " b=" << b << '\n'; }
};

int _tmain(int argc, _TCHAR* argv[])
{
	ClsA aa(10), *pa;
	ClsB bb(20, 30);

	aa.disp();
	bb.disp();

	pa = &bb;
	pa->disp();
	cout << "getA " << pa->getA() << '\n';
	//cout << "getB " << pa->getB() << '\n';	// エラー

	MessageBox(NULL, _T("Check Console Window"), L"MessageBox", MB_OK);

	return 0;
}

