gpt4 book ai didi

C++ 头文件和类文件 - undefined reference

转载 作者:行者123 更新时间:2023-11-27 23:20:58 25 4
gpt4 key购买 nike

<分区>

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

我得到了

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

为什么?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com