C++ 未解析的外部符号,即使已定义?

C++ 未解析的外部符号,即使已定义?,c++,lnk2001,C++,Lnk2001,我没有使用任何模板,而且它不是静态类或函数,所以我完全不知道它在定义时为什么会抛出LNK2001错误。 以下是全部错误: 1>mapgenerator.obj : error LNK2019: unresolved external symbol "private: class std::vector<int,class std::allocator<int> > __thiscall MapGenerator::Decode(class std::basic_st

我没有使用任何模板,而且它不是静态类或函数,所以我完全不知道它在定义时为什么会抛出LNK2001错误。 以下是全部错误:

1>mapgenerator.obj : error LNK2019: unresolved external symbol "private: class std::vector<int,class std::allocator<int> > __thiscall MapGenerator::Decode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?Decode@MapGenerator@@AAE?AV?$vector@HV?$allocator@H@std@@@std@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@@Z) referenced in function "private: void __thiscall MapGenerator::GenerateTileLayer(class TiXmlNode *)" (?GenerateTileLayer@MapGenerator@@AAEXPAVTiXmlNode@@@Z)
我不知道为什么它在抱怨,当一切看起来都合适的时候。 另一方面,我尝试让函数采用const char*const而不是std::string,因为Value()返回的是const char*const,但我仍然收到LNK2001错误。 有什么想法吗

你应该做:

std::vector<int> MapGenerator::Decode(std::string data)
{
std::向量映射生成器::解码(std::字符串数据)
{
您应该执行以下操作:

std::vector<int> MapGenerator::Decode(std::string data)
{
std::向量映射生成器::解码(std::字符串数据)
{
因为它是
MapGenerator
类的成员函数


因为它是
MapGenerator
类的成员函数。

您忘记将
MapGenerator::
添加到您的定义(of
Decode
)中。您忘记将
MapGenerator::
添加到您的定义(of
Decode
)@DanielMartin我们犯错误是因为我们是人类而不是超人。不客气。@DanielMartin我们犯错误是因为我们是人类而不是超人。不客气。
std::string test(node->FirstChild("data")->Value());
data = Decode(test);
std::vector<int> MapGenerator::Decode(std::string data)
{
 std::vector<int> Decode(std::string data)
 std::vector<int> MapGenerator::Decode(std::string data)
                  //^^^^^