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 templated swap function and data types.
template<class T> void swap( T& a, T& b ){ T tmp = a; a = b; b = tmp; } char c1, c2; int i1, i2; float A[10];
Which of the following calls to swap produces a compile time error?
What, if anything, is wrong with the following function declaration?
template<class A, class B> A f( B x );
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?
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?