I was having the same problem, so i did some research:
excerpt from : http://www.comeaucomputing.com/techtalk/templates/
Why do I get a link error when compiling my templates?
Some compilers require that all function templates need to be made available in every translation unit that it is used in. In effect, for those compilers, the bodies of template functions must be made available in a header file. To repeat: that means those compilers won't allow them to be defined in non-header files such as .cpp files. Furthermore, some compilers also require that some functions be defined inline inside a class, and not outside of one.
Note that not all compilers require this. For instance, Comeau C++ does not in all cases (check out http://www.comeaucomputing.com/4.0/docs/userman/ati.html for details on our current setup). In short, Comeau C++ supports many models, including one which comes close to what the export keyword's intentions are (as an extension).
hope this helps
Solution I suggest is that
Rename your cpp file to tcc(template cc)
And at the end of your Header file use this statement
#include "a.tcc"
Make sure that you have no include to a.h in your a.tcc file.