No older revisions available
No older revisions available
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;
}