Pete Becker posted:
Haven't you gotten the word? Macros are evil. This is the 21st century.
Quaint C approaches should never be used. Templates, templates,
templates. Always.
Exceptions, exceptions, exception -- and not the kind you throw!
C++ has many "warts" (if you wish to call them that) which perpetuate from
its origins in C. We have accepted these warts, documented them, and moved
forward.
When you want to give something a name in C++ (be it a function, an object,
a class), then you don't need to pick a very unique name, because all you
need do is enclose it in a namespace:
namespace MyNamespace { int cout; }
Macros muck this up completely. However, there is a finite list of macros
which the Standard defines, such as:
INT_MAX
UCHAR_MAX
CHAR_BIT
As always, the Standard can take liberties wherever it pleases, and it
chooses to define these macros. If you genuinely perfer the numeric_limits
method, then go ahead. However, I myself find it awfully tedious and
longwinded, and I prefer good ol' CHAR_BIT.
While one should hesitate to define macros (for the obvious reasons),
there's no need to hesitate to use the ones that are already there, and
which will _always_ be there. Never will we be able to write:
int CHAR_BIT = 5;
Also, you might notice that "max" and "min" don't evaluate to a compile-
time constant, which make INT_MAX and the like all the more attractive.
--
Frederick Gotham