I'm getting an undefined reference linker error with the following. I understand that the object code is not being generated but I'm not sure how to change that.
templ_main.cpp
templ.hCode:#include "templ.h" int main (void) { print(1); print('c'); print("Hello World"); return 0; }
templ.cppCode:#ifndef TEMPL_H_ #define TEMPL_H_ template <typename T> void print(T); #endif
Any ideas on how to force the compiler to generated the needed object code?Code:#include "templ.h" #include <iostream> template <typename T> void print(T var) { std::cout<<var<<endl; }