I got this problem: template<class T> Tmax<Ta,Tb,,Tc> | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I got this problem: template<class T> Tmax<Ta,Tb,,Tc>

return Ta>Tb&&Ta>Tc? Ta: Tb>Ta && Tb>Tc? Tb:Tc. at main: cout<<Tmax(4, 15.5, 7.4); Answer: should be 15.5 is the max, but 15.5 is not int type or Tb. So it must be next option is the correct answer: Error Will be caused. My question is: Which one is the correct : "ERROR WILL BE CAUSED" OR "ERROR WILL OCCUR".

23rd Sep 2022, 7:50 PM
Oliver Pasaribu
Oliver Pasaribu - avatar
2 Answers
+ 1
#include <iostream> using namespace std; template<class T> T max(T a, T b, T c) { return a>b && a>c ? a : b>a && b>c ? b : c ; } int main() { cout << max <double> ((double)4, 15.5, 7.4); return 0; } https://www.sololearn.com/compiler-playground/clenF6mFg7V7
23rd Sep 2022, 8:42 PM
SoloProg
SoloProg - avatar
0
Solo link can not be open or accessed.
23rd Sep 2022, 9:06 PM
Oliver Pasaribu
Oliver Pasaribu - avatar