jeudi 27 février 2020

C++ Linker error on template class and template function [duplicate]

Test.h

typedef enum oflags_t : uint8_t
{
    FLAG_CREAT = O_CREAT  
  , FLAG_RONLY = O_RDONLY  
  , FLAG_RDWR = O_RDWR  
} oflags_t;

template <uint8_t flags>
class Test {

public:

    template <uint8_t flags_in = flags>
    Test(const std::string &p_name);

};

using Test_1 = Test<FLAG_RONLY>;

Test.cpp

template <uint8_t flags>
template <uint8_t flags_in>
Test<flags>::Test(const std::string &p_name) {

}

template class Test<FLAG_RONLY>;

main.cpp

 Test_1 obj1("Obj");

When i try to build this, i get linker error "unresolved external symbol...".

What can i do to solve the issue? Thank you.

Aucun commentaire:

Enregistrer un commentaire