I need help to understand what I'm supposed to do in this question
I'm not asking for a code what I need is explanation
thanks a lot

write a function template that
returns the range of values stored in a vector <T>that is the
difference between the
largest value and the smallest value
where operator is assumed to be degind for type T

Recommended Answers

All 2 Replies

It seems fairly well explained as it is.
What more do you need?

A for loop to iterate over the members of the vector perhaps?

Actually it is quite vague.

To my mind, the most probable meaning is that you are to write a function that takes a vector as argument, finds both the largest and smallest values in the vector, and returns (largest minus smallest).

Read another way, you might have to write a function that takes two values and returns a vector iterating from the smallest to the largest.

Either way, the type T must have collative properties (having at least operator< defined) and additive properties (having operator+ and/or operator- defined). A good type T would be int, for example.

I would go and ask your professor for clarification.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.