In a template function, _____ argument is generic, or parameterized

no
exactly one
at least one
more than one

The correct answer is: C. at least one

A template function is a function that can be used with different types of data. The types of data that a template function can be used with are called template arguments. A template function can have any number of template arguments, but it must have at least one.

For example, the following is a template function that takes two template arguments, T and U:

template <typename T, typename U>
T add(T a, U b) {
return a + b;
}

This function can be used with any two types of data. For example, we can use it to add two integers:

int a = 1;
int b = 2;
int c = add(a, b);

Or we can use it to add two strings:

string a = "Hello";
string b = "World";
string c = add(a, b);

The add function is a generic function because it can be used with any type of data. The T and U template arguments allow us to specify the types of data that the function will be used with.

The following are some examples of incorrect answers:

  • A. no This is incorrect because a template function must have at least one template argument.
  • B. exactly one This is incorrect because a template function can have any number of template arguments.
  • D. more than one This is incorrect because a template function must have at least one template argument.
Exit mobile version