0

Possible Duplicate:
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)]++;
}

I am getting

arithmeticcoding.cpp:-1: error: undefined reference to `ArithmeticCoding::letters_freq'

Why?

Community
  • 1
  • 1
c0dehunter
  • 6,412
  • 16
  • 77
  • 139

1 Answers1

4

Add this to exactly one of your CPPs

 QMap<QChar,int> ArithmeticCoding::letters_freq;
Robᵩ
  • 163,533
  • 20
  • 239
  • 308