If I define a function such as the following, the compiler has no problems with it.
void
findMin ( vector <int> vec, vector<int>::iterator first, vector <int>::iterator last)
{
vector <int>::iterator posSmall = min_element (first, last);
cout <<"Smallest element is " <<vec[*posSmall] << endl;
}
however, as that can only handle integers, from what I understand could create a template like the following.
template <typename T>
void
findMin ( vector <T> vec, vector<T>::iterator first, vector <T>::iterator last)
{
vector <T>::iterator posSmall = min_element (first, last);
cout <<"Smallest element is " <<vec[*posSmall] << endl;
}
The comiler however gives me errors such as
error: class std::vector<T, std::allocator<_CharT> >::iterator' is not a type