Write a function template for a function named minimum. The function will have two parameters of the same type. It returns the smaller of these (either if they are equal.)

In carrying this out, give:
a) a prototype (declaration) and preconditions for the function template
b) a definition for this function.
c) As a part of your answer, remark on the restriction of this function template to types for which operator< defined.


a). The declaration and precondition are:
```
// Precondition: T is a type for which operator< is
// defined
// Postcondition: function returns the smaller argument
template
T minimum( T left, T right);
```
b) The definition is:
```
template
T minimum(T left, T right)
{
if ( left < right )
return left;
return right;
}
```
c). The minimum function uses operator<. The compiler will produce an error, and refuse to compile the program if a type is used for which operator< is not defined.

Computer Science & Information Technology

You might also like to view...

Give a brief intuitive argument for the necessity of each individual condition.

What will be an ideal response?

Computer Science & Information Technology

The action of copying or moving cells contents to another location is called ________

Fill in the blank(s) with correct word

Computer Science & Information Technology

Which connection type is limited to point-to-point topology and uses a 25-pin female DB type?

A. BNC B. LC C. Parallel D. Serial

Computer Science & Information Technology

A(n) ____________________ is an objective test or measurement used to evaluate the speed, capacity, capabilities, or productivity of competing technology products.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology