c++ 单例模式 编译提示无法解析的外部命令,程序哪里错了。。。
#include <iostream>
using namespace std;
class A {
private:
A(){};
static A *a;
public:
static A &getA(){
if(a==NULL){
a = new A();
}
return *a;
}
};
//A A::*a=NULL;
int main(){
A::getA();
system("pause");
return 0;
}
编译提示下面错误:
1>test141130_sin.obj : error LNK2001: 无法解析的外部符号 "private: static class A * A::a" (?a@A@@0PAV1@A)
1>G:\达内学习\达内学习笔记\C++\day05\Debug\day05.exe : fatal error LNK1120: 1 个无法解析的外部命令