Rearrange the code to declare a template function "greater", taking two arguments and returning the greater one. Arguments are o | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 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) {

21st Oct 2016, 5:33 AM
anjanel macalaguim
9 Answers
+ 6
3. 4. 6. 1. 2. 5.
21st Oct 2016, 4:53 PM
Lara
Lara - avatar
+ 2
template <class T, class U> T greater(T a, U b) { if (a > b) { return a; } return b; }
7th May 2018, 10:47 AM
abdiwahab jama said
abdiwahab jama said - avatar
+ 1
template <class T, class U> T greater(T a, U b) { if (a > b) { return a; } return b; }
19th Mar 2018, 2:24 PM
Mahnoor Shahzad
Mahnoor Shahzad - avatar
0
3 4 6 1 2 5
29th Oct 2018, 7:35 PM
Isaiah Waterman
Isaiah Waterman - avatar
0
template<class T,class U> T greater(T a,U b) { if(a > b) { return a; } return b; }
10th Sep 2019, 7:58 PM
Kaleem Ullah
Kaleem Ullah - avatar
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; }
22nd Feb 2020, 1:41 PM
Ragavi Madhu
0
3 4 6 1 2 5
9th May 2020, 2:20 AM
leela Marisetti
leela Marisetti - avatar
0
3 4 6 1 2 5
9th May 2020, 2:22 AM
leela Marisetti
leela Marisetti - avatar
0
template <class T, class U> T greater(T a, U b) { if (a > b) { return a; } return b; }
8th Nov 2020, 2:09 PM
Julita Widya Sari Br Manurung
Julita Widya Sari Br Manurung - avatar