- 2
Rearrange the code to declare a template function "greater", taking two arguments and returning the greater one. Arguments are o
1. return a; } 2. return b; 3. template <class T, class U> 4. T greater(T a, U b) { 5. } 6. if (a > b) {
9 Answers
+ 6
3.
4.
6.
1.
2.
5.
+ 2
template <class T, class U>
T greater(T a, U b) {
if (a > b) {
return a; }
return b;
}
+ 1
template <class T, class U>
T greater(T a, U b) {
if (a > b) {
return a; }
return b;
}
0
3
4
6
1
2
5
0
template<class T,class U>
T greater(T a,U b) {
if(a > b) {
return a; }
return b;
}
0
Drag and drop from the options below to declare a template function with two arguments. The function returns the sum of its arguments. The arguments are of template type T.
answer:
template <class T>
T sum(T a, T b)
{
return a + b;
}
0
3
4
6
1
2
5
0
3
4
6
1
2
5
0
template <class T, class U>
T greater(T a, U b) {
if (a > b) {
return a; }
return b;
}