0

I have a class called A and a function that needs to have a template. It is declared like this in the header:

class A{
    public:
        template <SIDE S>
        void foo();
}

And in the source file:

template<SIDE S>
void A::foo(){
    /* ... */
}

But this results in a linker error (LNK2001 for MSVC).

How do I solve this? It will be pretty cumbersome to have to repeat code for one function if templates doesn't work...

BimmerBass
  • 33
  • 4
  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix). See [this](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix/12574417#12574417) answer – Timo Mar 09 '21 at 09:08
  • Yes it does. I wan't able to find anything about this before, but thank you! – BimmerBass Mar 09 '21 at 09:12

0 Answers0