变量声明:
template <class T, enum EDeviceType g_eDeviceType> class ILocalDeviceProtocolImpl : public T { public: ILocalDeviceProtocolImpl(){}; protected: static const QString m_strModuleName; };
在另一个文件里变量初始化:
template <> const QString ILocalDeviceProtocolImpl<ILocalPhdProtocol,DT_LOCALPRINTHEAD>::m_strModuleName = "LCLPHDPCOL: ";
注意:需要在变量初始化前面加上 template <>
标签:初始化,变量,C++,类中,template,ILocalDeviceProtocolImpl,模板,QString From: https://www.cnblogs.com/ghnie/p/17122937.html