Dear all,
I'm creating a set of functions to handle stl vectors. Some are useful for achieving my goals. I'm coding some other just for fun. But after some coding I see I cannot compile them propperly.
One example would be a vector print function which prints all the elements of a vector of an arbitrary type.
--- vecTools.h---
template <typename T>
void printVector (T &v1);
--- vecTools.cpp---
#include "vecTools.h"
template <typename T >
void printVector ( T &v1){
cout<<"[ ";
for (unsigned int i =0; i < v1.size(); i++){
cout<<v1[i]<<", ";
}
cout<<"] \n";
}
The answer of the g++ compiler is as follows:
../src/Tools/Test/main.cpp:39: undefined reference to `void printVector<DummyObject>(std::vector<DummyObject, std::allocator<DummyObject> >&)'
collect2: ld returned 1 exit status
make: *** [core_iteration1] Error 1
Do you know how can one fix this? Maybe it's impossible?
Many thanks!!
Víctor