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".
2 Réponses
+ 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
0
Solo link can not be open or accessed.