Original Post
I have the following code samples that I have written deliberately omitting the mention of header files that I have included, // helper.h #ifndef _HELPER_H_ #define _HELPER_H_ namespace CppTemplate001 { class Helper { public: Helper(); ~Helper(); template static T compare(T a, T b); private: }; } #endif // _HELPER_H_ // helper.cpp Helper::Helper() { } Helper::~Helper() { } template T Helper::compare(T a, T b) { if (a < b) return a; return b; } // main.cpp int main(int argc, char **argv) { int a = 10; int b = 50; int c = 0; c = Helper::compare(a, b); cout << c << endl; return EXIT_SUCCESS; } I wanted to achieve something like having static helper methods to be housed in a class but not making the class generic, I wanted to define different generic templates for certain methods and not all of them. Is it possible to do this? The code compiles well before I called Helper::compare() from main.cpp. When I include that line otherwise, it fails to compile giving me a linker error not able to resolve the symbol. So I can't do it this way, can I?