#include <iostream>
#include <cstdlib>
#define for if(0);else for // VC++ 6.0
using std::cout;
using std::cin;
using std::endl;
class Configure
{
private:
Configure() {} ; ///// 原题掉了 {} .......所以编译通不过!
public:
static Configure* Instance();
public:
int GetConfigureData() { return data;}
int SetConfigureData(int m_data) { data = m_data; return data; }
private:
static Configure* _instance;
int data;
};
Configure* Configure::_instance = NULL;
Configure* Configure::Instance()
{
if ( _instance == NULL)
{
_instance = new Configure;
}
return _instance;
}
int main( )
{
Configure* t = NULL;
t = t->Instance();
int d = t->GetConfigureData();
system("pause");
return 0;
}
本文地址:http://com.8s8s.com/it/it25643.htm