+ 1
Sololearn C++ Practice 76.2 Functions! Help please I’m stuck!
#include <iostream> using namespace std; //your code goes here template <class T> T myMax(T a, T b){ return b; } int main () { double x, y; cin>>x>>y; int a, b; cin>>a>>b; cout << myMax(x, y) << endl; cout << myMax(a, b) << endl; } This is my working out somehow I don’t know how to make it output the fourth one: b I tried this already: T myMax (T a, T b, T c, T d){ return b; return d; } But it did not work pls help! 🥺
2 Respuestas
+ 5
template <class T>
T myMax(T n1, T n2)
{
if (n1>n2) return n1; else return n2;
}
// Keep learning & happy coding :D
+ 1
Thank you for all your support!