-Write a function template that returns the range of values stored in a vector, that is, the difference between the largest value and the smallest value, when operator < is assumed to be defined for type T.
This is what I have:
template <typename T>
int Range(vector<T> vec)
{
for(int i = 0; i < (vec.size() - 1); i++)
{
while (vec[i] < vec[i + 1])
{
return (vec.begin() - vec.end());
}
}
}
How does this look? Feedback and criticism is appreciated. Thanks :)


Sign In
Create Account

Back to top









