The template mechanism in C++ makes separate compilation very difficult. Traditional linkers are inadequate. Consider the following oversimplified example where a class and its methods and the client program (main) are all in one file. // This version has everything in one file (class,methods,main). template class MyClass { T val; public: void set( T x) { val = x; } T get( ) { return val; } }; #include main() { MyClass object; object.set(31459); cout << object.get(); } This by itself is no problem for the compiler/linker. Note that the methods in this version are inline which is not always desirable. The following version moves the methods out of the class so that they are no longer inline. // This version has everything in one file (class,methods,main). // The methods in this version are not inline. template class MyClass { T val; public: void set( T x) ; T get( ) ; }; template void MyClass:: set( T x) { val = x; } template T MyClass:: get( ) { return val; } #include main() { MyClass object; object.set(31459); cout << object.get(); } Note the prefix "template " in front of each method and the class name "MyClass::" must include the generic type "" suffix. It is generally considered good practice to define each class in a separate header file ( e.g. "MyClass.h") which might appear as follows: #ifndef MyClass_H #define MyClass_H template class MyClass { T val; public: void set( T x) ; // method prototypes only T get( ) ; }; template void MyClass:: set( T x) { val = x; } template T MyClass:: get( ) { return val; } #endif Each client program (e.g. main()) should: #include "MyClass.h" This works fine. C programmers may not be happy having the code for the methods appear in a header file. If several different modules happen to instantiate MyClass using the same type then the linker may link more than one copy of the methods into the executable program. Most programmers put the code for the methods into a separate file (e.g. "MyClass.cc") which can be compiled separately: #include "MyClass.h" template void MyClass:: set( T x) { val = x; } template T MyClass:: get( ) { return val; } Of course, the last two lines would be truncated in the header file. This could be compiled using "g++ -c MyClass.cc". The problem is that at the time these methods are compiled the compiler does not know which particular types T to compile the methods for. The gcc/g++ online manual discusses three different solutions to this problem. See "info gcc" chapter 9 (C++ Extensions) section 5 (Template Instantiation). The most straightforward approach is the add an extra line to MyClass.cc explicitly specifying which types the compiler should compile the methods for. E.g template class MyClass; To summarize, you would create a header file containing only the class declaration: //file MyClass.h #ifndef MyClass_H #define MyClass_H template class MyClass { T val; public: void set( T x) ; // method prototypes only T get( ) ; }; #endif Your main program might look like: #include "MyClass.h" #include main() { MyClass object; object.set(31459); cout << object.get(); } Since MyClass is only being instantiated for type = the file MyClass.cc would appear as follows: #include "MyClass.h" template void MyClass:: set( T x) { val = x; } template T MyClass:: get( ) { return val; } template class MyClass; Later on if you modify the main program to use an object of type MyClass then you would need to add "template class MyClass;" to the file MyClass.cc and recompile both the main program and MyClass.cc.