// 25_25-9.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <cstring>

using namespace std;

class Mystring {
public:
	char *text;
public:
	Mystring(char *ss);				// コンストラクタ宣言
	Mystring(const Mystring& obj);	// コピーコンストラクタ
	~Mystring();					// デストラクタ宣言
	void disp() { cout << "text=" << text << '\n'; }
};

Mystring::Mystring(char *ss)
{
	text = new char[strlen(ss)+1];
	strcpy(text, ss);
}

Mystring::Mystring(const Mystring &obj)
{
	text = new char[strlen(obj.text)+1];	// 新しくメモリ確保
	strcpy(text, obj.text);	// objの文字列コピー
}

Mystring::~Mystring()
{
	delete[] text;	// メモリ解放
}

int _tmain(int argc, _TCHAR* argv[])
{
	Mystring ss1("abcde");
	Mystring ss2 = ss1;
	ss1.disp();
	ss2.disp();

	MessageBox(NULL, _T("Check Console Window"), L"MessageBox", MB_OK);

	return 0;
}

