I have a class template A
which looks like this:
A.h
template <typename T>
class A
{
T data;
public:
A(void) { };
~A(void) { };
void addItem(T d);
}
A.cpp
template <typename T>
void A<T>::addItem(T data)
{
};
And another class template B
which looks like this:
B.h
#include "a.h"
class B : public A<int>
{
public:
B(void) : A<int>() {};
~B(void) {};
void doSomething();
};
B.cpp
#include "B.h"
void B::doSomething()
{
addItem(1);
}
When compiling this under VS 2012 I get an error which says:
error LNK2019: unresolved external symbol "public: void __thiscall A::addItem(int)" (?addItem@?$A@H@@QAEXH@Z) referenced in function "public: void __thiscall B::doSomething(void)" (?doSomething@B@@QAEXXZ)
Why isn't the addItem()
member function resolvable? Can you please recommend a way to fix this?