U E D R , A S I H C RSS

05학번만의C++Study/숙제제출4/조현태

느낀점

소스

main.cpp


~cpp
#include <iostream>
#include "TestClass.h"

using namespace std;

const int MAX_CLASS=255;

void main()
{
	int intinput;
	TestClass* makedClass[MAX_CLASS];
	int classNumber=0;
	while(1)
	{
		cin >> intinput;
		if (0==intinput)
			break;
		int suchNumber=-1;
		for (register int i=0; i<classNumber; ++i)
		{
			if (intinput==makedClass[i]->GetNumber())
				suchNumber=i;
		}
		if (-1==suchNumber)
		{
			makedClass[classNumber]=new TestClass(intinput);
			++classNumber;
		}
		else
		{
			delete makedClass[suchNumber];
			for (register int i=suchNumber+1; i<classNumber; ++i)
				makedClass[i-1]=makedClass[i];
			--classNumber;
		}
	}
	for (register int i=0; i<classNumber; ++i)
	{
		delete makedClass[i];
	}	
}

TestClass.h


~cpp

class TestClass
{
private:
	int m_haveInt;
public:
	TestClass(int inputNumber);
	~TestClass();
	int GetNumber();
};

TestClass.cpp


~cpp

#include "TestClass.h"
#include <iostream>

using namespace std;


TestClass::TestClass(int inputNumber)
{
	cout << "클래스가 생성되었습니다.\n";
	m_haveInt=inputNumber;
}
TestClass::~TestClass()
{
	cout << m_haveInt << "을 가진 클래스가 파괴되었습니다.\n";
}
int TestClass::GetNumber()
{
	return m_haveInt;
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0149 sec