Which of the following options is most suitable?
#include <iostream>

//...

// 1
inline int const& max(int const& a, int const& b)
{
    return a < b ? b : a;
}

// 2
template<typename T> 
inline T const& max (T const& a, T const& b)
{
    return a < b ? b : a;
}

//...
int main() 
{ 
    //...
    std::cout << ::max('a', 42.7) << std::endl; //3
    //...
    
    return 0; 
} 

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes