J
James Kuyper
jacob said:max(a,b)
min(a,b)
As pointed out elsethread, this needs a special template
and generic functions in C++. Imagine.
In C a simple macro is enough.
Whatever macro definition you're thinking of, it will probably work just
as well in C++; if you do something unnecessarily complicated, it's
possible but unlikely that it might need a re-write.
A generic function template is used in C++, not because it's necessary
to achieve the same functionality as the C macro you are thinking of,
but because the template allows different functionality. It provides
greater type safety and makes it trivial to avoid double-evaluation of
the arguments. The use of a function template also enables definition of
the overloaded version of max(), which uses a user-specified function
object to perform the comparison, rather than using '<'.