From: Michael P. <mdp...@ya...> - 2001-05-22 14:40:36
|
Templates are more like Macros. Glorified Macros but macro like all the same. When you create an instance of a template, the compiler needs all of the information immediately to create it. It will not be able to leave it to the linker like a regular class. This makes sense since the instance construction is dependent upon the data types feed to the template. Each template method construction is dependent upon these data types. --- Graeme Foster <gr...@dr...> wrote: > 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 > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ |