stack

#include <stack>

typedef std::stack<Test*> Tests;

class TestManager
{
Tests m_stack;

public:
TestManager();
virtual ~TestManager();

Test* pop();
void push( Test* test );
};

TestManager::TestManager()
{
}

TestManager::~TestManager()
{
int count = (int)m_stack.size();
for( int i=0; i<count; i++ ){
Test* test = m_stack.top();
delete test;
m_stack.pop();
}
}

/**
* 返した先でtestをdeleteしなくてはいけない
*/
Test* TestManager::pop()
{
Test* test = m_stack.top();

m_stack.pop();

return test;
}

void TestManager::push( Test* test )
{
m_stack.push( test );
}
最終更新:2009年03月09日 10:39
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。