I do not have a .cpp file because I am using a template. But I still met an unresolved issue with external characters. Does anyone know the reason? Thanks so much if you can help me.
template<class T>
class SQLiteHelper
{
public:
static SQLiteHelper<T>* getInstance(T* factory)
{
if (NULL == m_sInstance)
{
m_sInstance = new SQLiteHelper<T>(factory);
}
return m_sInstance;
}
private:
SQLiteHelper<T>(T* factory) { m_factory = factory; }
private:
static SQLiteHelper<T>* m_sInstance;
sqlite3* m_database;
T* m_factory;
std::string m_dbPath;
};
and the problem occurs when I called:
AudioItem item;
AudioDBHelper<AudioItem>::getInstance(&item);
Question:
error LNK2001: unresolved external symbol \"private: static class SQLiteHelper<class AudioItem> * SQLiteHelper<class AudioItem>::m_sInstance" (?m_sInstance@?$SQLiteHelper@VAudioItem@@@@0PAV1@A)
source
share