From: Graeme F. <gr...@dr...> - 2001-05-22 05:31:31
|
I have created a template, as follows: template <class T,long px=0, long py=0, long pz=0> class c3DMatrix { private: // Private member functions and variables protected: // Protected member functions and variables public: // Public member functions and variables }; template <class T,long px, long py, long pz> T c3DMatrix<T, px, py, pz>::get(long x, long y, long z) { // some code to return the appropriate element } When I include the declaration and source code in the C++ header file everything works correctly. However if I remove the source code out to a separate cpp file I get a linker error as follows: undefined reference to 'c3DMatrix<int,5,2,4>::get(long,long,long) source code is as follows... #include "c3DMatrix.hpp" template <class T,long px, long py, long pz> T c3DMatrix<T, px, py, pz>::get(long x, long y, long z) { // some code to return the appropriate element } All three files (header, source and driver file are include in the project) Any advice greatly appreciated. Graeme |