In a template definition
template<class T> ...
the template parameter T ranges over
Consider the following template specification.
template<int n> ...
In use, the template parameter n can be replaced by
Consider the following templated array copy function and arrays.
template<class T> void copy( T a[], T b[], int n ) { for(int i = 0; i < n; i++ ) a[i] = b[i]; } char C[10], CC[10]; int I[10]; float F[10];
Which of the following calls to copy would produce a compile time error?
Consider the following outline of a templated sorting function.
template<class T> void sort( T a[], int n ) { ... }
For a given sorting algorithm S, which of the following is true about using this outline to implement S?
Consider the following outline of a templated array class.
template<class T> class Array { ... }
Which of the declarations below is in obvious error with respect to using such a class?
Which of the following declarations are in error with respect to using such a class?
Consider the following templated function.
template<class T> T Apply( T x, T (*ff)(T) ){ return ff(x); }
Which of the following is true concerning its use?
template<class Func> void mystery( Func f, int n, typename Func::result_type& x ) { for( int i = 0; i < n; i++ ) x += f(i); }
If the first actual parameter of a call to mystery is a function object f that properly defines result_type and if n0 and x0 are the values of the second and third actual parameters, which of the following accurately describes the result of executing that call?