标签:style blog color sp div on 问题 log as
Singleton.h
class Singleton{ public: static Singleton* getInstance(){ if(instance == NULL){ instance = new Singleton(); } return instance; } private: static Singleton * instance; Singleton(){}; }; Singleton* Singleton::instance = NULL;
main.cpp
int main(){ Singleton * instance = NULL; instance = Singleton::getInstance(); return 0; }
原因在于仅声明了Singleton类的静态变量instance,但缺少变量定义,造成“无法解析的符号”错误。
标签:style blog color sp div on 问题 log as
原文地址:http://www.cnblogs.com/jasonkent27/p/4101627.html