做项目中犯了一个非常低级的错误,现在记录,警醒自己。
在使用静态成员变量之前,一定要初始化!!
同时 静态函数只能使用静态的成员变量
如:
在xxx.h中声明如下的类
class CarProtocolInfoHandle{
private:
//线程操作
static HANDLE m_ProgressThread;
static long prorange;
static long propos;
//诊断操作类
Diagdatahandle ddh;
int m_MostGroupNameLength;
int m_MostItemLength;
int m_MostUnitLength;
.....
}
那么在对应的xxx.cpp文件中,就需要进行初始化(不能再成员函数中),如下。
HANDLE CarProtocolInfoHandle::m_ProgressThread = 0;
long CarProtocolInfoHandle::prorange = 0;
long CarProtocolInfoHandle::propos = 0;
持续记录脑残的低级错误,不要畏惧他给你带来的耻辱。