可能重复:
What is an undefined reference/unresolved external symbol error and how do I fix it?
·H:
class ArithmeticCoding
{
public:
ArithmeticCoding();
static void test(QString text);
static QMap<QChar,int> letters_freq;
}
的.cpp:
QMap<QChar, int> letters_freq;
ArithmeticCoding::ArithmeticCoding()
{
}
void ArithmeticCoding::test(QString text)
{
for(int i=0; i<text.length(); i++) letters_freq[text.at(i)]++;
}
我正在
arithmeticcoding.cpp:-1:错误:未定义引用 `ArithmeticCoding :: letters_freq'
为什么?
答案 0 :(得分:4)
将其添加到您的一个CPP中
QMap<QChar,int> ArithmeticCoding::letters_freq;