#include <iostream>
#include <cstring>
namespace mySpace{ // getting sure that this is the class we are calling, std::max is already implemented
template < class T > // for any class/typename T
inline const T& max (const T& a, const T& b){ //
return a>b?a:b; // where the operator '>' is implemented
}
}
int main(){
int a = 10, b=20;
float c = 10.2, d = 10.1;
std::string e = "a";
std::string f = "aa";
std::cout << mySpace::max(a,b) << std::endl;
std::cout << mySpace::max(c,d) << std::endl;
std::cout << mySpace::max(e,f) << std::endl;
std::max(a,b);
return 0;
}
read more ->
No comments:
Post a Comment