Hey Everybody,
Question, suppose that I want to write a function that prints out an STL vector of anything that implements a << operator. I am trying to do it like this:
template <class C>
void print(vector<C> & v)
{
for(int i = 0; i < v.size(); ++i)
{
cout << v[i] << " ";
}
}
What is wrong with this? How could I revise this to make it work?
Question, suppose that I want to write a function that prints out an STL vector of anything that implements a << operator. I am trying to do it like this:
template <class C>
void print(vector<C> & v)
{
for(int i = 0; i < v.size(); ++i)
{
cout << v[i] << " ";
}
}
What is wrong with this? How could I revise this to make it work?
Comment