## 22.1 Template Functions (cont.)

- `T` is arbitrary; any legal C identifier
- `typename` (or `class`) indicates that the value of `T` will be a type
- `T` could represent any type
- Its type is inferred from the arguments of the call:

  >     int a[] = {2, 4, 5};
  >     print(cout, a, 3); // Will use int print
  >     double b[] = {3.14159, 2.7};
  >     print(cout, b, 2); // Will use double print
  >     string c[] = {"Fred", "Sally", "Alice"};
  >     print(cout, c, 3); // Will use string print

- Within the function body `T` can be used wherever that type would be appropriate

prev |top |next