I am using gcc on cygwin to compile the following code;
Code:
template<class C>
ostream & operator<<(ostream & os, const vector<C> & v) {
os << "Vector of size " << (int)v.size() << " contains :" << endl << " | ";
for ( typename vector<C>::const_iterator iter = v.begin();
iter != v.end();
++iter ) {
os << *iter << " | ";
}
os << endl;
return os;
}
Code:
#include "utilities.h"
#include <iostream>
#include <vector>
int main() {
std::vector<int> v(10,10);
std::cout << v << std::endl;
return 0;
}
when I try to link I get this error:
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& operator<< <int>(std::basic_ostream<char, std::char_traits<char> >&, std::vector<int, std::allocator<int> > const&)'
any ideas? thanks