単純な単一の実装

585 ワード

//////test.h
class test
{
public:
	~test(void);
	static test* GetInstance();
	int Geta();
private:
	static test m_instance;
	test(void);
	int a;
};

//////test.cpp
test::test( void )
{
	a = 10;
	printf("create test!
"); } test::~test( void ) { printf("destroy test!
"); } test* test::GetInstance() { return &m_instance; } int test::Geta() { return a; } test test::m_instance;
void main()
{

	printf("test a:%d
",test::GetInstance()->Geta()); getchar(); }