+ 1

How can it return b

b is of type U but return type of the function is T template <class T, class U> T smaller(T a, U b) { return (a < b ? a : b); }

6th May 2018, 4:04 AM
Samar Singhai
Samar Singhai - avatar
3 Antworten
+ 2
I understand now It will return T type only First it will convert b into T type and return it
6th May 2018, 4:24 AM
Samar Singhai
Samar Singhai - avatar
+ 7
You may need a refresher on templates. http://www.cplusplus.com/doc/oldtutorial/templates/
6th May 2018, 4:45 AM
jay
jay - avatar
0
What? Post your code please
6th May 2018, 4:15 AM
Ole113
Ole113 - avatar