I am wondering what's wrong with template parameter in print()?
I was tring to use print without specifying template argument.
This is the error I got.
error C2784: 'void print(const C<T> &)' : could not deduce template argument for 'const C<T> &' from 'std::vector<_Ty>'
Code:#include <vector> #include<iostream> #include <iterator> using namespace std; template<typename T, template<class > class C > void print(const C<T> &x) { copy(x.begin(), x.end(), ostream_iterator<T>(cout," ")); cout << endl; } int main() { vector<double> v; v.push_back(100); print(v); }




Reply With Quote