错误LNK2019:无法解析的外部符号?

时间:2019-09-08 09:14:25

标签: c++

我收到这些错误消息

我认为sde_lib.cpp有问题。链接器找不到他。因为没有文件编译是好的。

  

1> main.obj:错误LNK2019:未解决的外部符号“ public:   __thiscall SDELibrary :: SDELibrary(class Example)“(?? $?0VExample @@@@ SDELibrary @@ QAE @ VExample @@@@ Z)   _main

这是main.cpp的代码

#include <iostream>
#include "sde_lib.h"


class Example
{
public:
    Example() : x(10), y(11), z(12) {}

private:
    int x, y, z;
};

int main()
{
    Example ex;
    SDELibrary sd(ex);

    std::cin.get();
}

这是sde_lib.h的代码

#pragma once
#include <iostream>

#include "../inc/tinystr.h"
#include "../inc/tinyxml.h"

class SDELibrary 
{
private:
    TiXmlDocument *m_doc;
    TiXmlDeclaration *m_decl;

public:
        SDELibrary() = delete;

        template <class T>
        SDELibrary(T obj);

        ~SDELibrary();

};

这是sde_lib.cpp的代码

#include "sde_lib.h"

template <class T>
SDELibrary::SDELibrary(T obj)
{

}

SDELibrary::~SDELibrary()
{
}

0 个答案:

没有答案