0
can I change the T with whatever I want like??
template <class numb, class Y> numb greater(numb a, Y b) { return (a > b ? a : b); } int main() { int x = 10; int y = 20; cout << greater(x,y) << endl; return 0; } //this code gonna work right??
2 Answers
+ 3
Yes it will work. But some cases if first parameter is int and second parameter is string undefined behaviour will happen in your conditional operator statement.
Apart from you can use anything instead of T.
0
OK thanks a lot