#include <iostream>using namespace std;class CSingleton{//其他成員public:static CSingleton* GetInstance();int age;private:CSingleton(){};static CSingleton* m_pInstance;};CSingleton* CSingleton::GetInstance(){if ( m_pInstance == NULL ) //判斷是否第一次調(diào)用m_pInstance = new CSingleton();return m_pInstance;}int main(){CSingleton* p1 = CSingleton::GetInstance();p1->age=10;cout<<p1->age;return 0;}
訪問類的靜態(tài)成員變量的時(shí)候出現(xiàn)undefined reference to
桃花長(zhǎng)相依
2018-12-30 00:00:14