Templated function being reported as “undefined reference” during compilation
These are my files: --------[ c.hpp ]-------- #ifndef _C #define _C #include<iostream> class C { public: template<class CARTYPE> void call(CARTYPE& c); }; #endif --------[ c.cpp ]-------- #include "c.hpp" template<class CARTYPE> void C::call(CARTYPE& c) { //make use of c somewhere here std::cout<<"Car"<<std::endl; } --------[ v.cpp ]-------- class Merc {}; --------[ main.cpp ]-------- #include "c.hpp" #include "v.cpp" //#include "c.cpp" int main() { Merc m; C someCar; someCar.call(m); }//main I'm able to generate ".o" files for all the above files, with the command g++ -c main.cpp and g++ -c c