Possible Duplicate:
Why do I get “unresolved external symbol” errors when using templates?
I'm trying to implement a generic Queue using templates.
I have the following code in my header:
template<class Item>
class Queue{
protected:
struct linked_list;
int size;
public:
Queue();
Queue(Item T);
};
I have a Queue.cpp:
template<class Item>
Queue<Item>::Queue()
{
}
template<class Item>
Queue<Item>::Queue(Item T)
{
}
but every time I compile, I get a linker error because of unresolved externals.
I reinstalled VS2012 twice (thinking the linker was broken), but the problem keeps appearing.
I read that there is some problem with the function implementations being in a separate file when working with templates, but I haven't seen any solution except putting the implementation in the header.
Is there a more elegant way to do so?