class MyClass{public: static MyClass * getInstance();private: MyClass(); static MyClass * m_pMyClass;};#define MyClassInstance (*MyClass::getInstance())
cpp文件MyClass * MyClass::m_pMyClass;MyClass::MyClass(){ m_pMyClass = Q_NULLPTR;}MyClass *MyClass::getInstance(){ if(Q_NULLPTR == m_pMyClass) { m_pMyClass = new MyClass(); } return m_pMyClass;}