"ashwani" <as*********@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
: Hi
: Can any one tell me the difference between preprocessor macros like
: #define and enum.
: If i want to define MAX_LIMIT=100 as preprocessor macro as
: #define MAX_LIMIT 100
: or if i define enum {MAX_LIMIT=100}; then what is the basic difference?
: Is there any efficiency tradeoff between both the definitions.
No difference in efficiency.
enum-declared constants are to be preferred because they
obey scoping rules (e.g. they can be encapsulated within
a class or namespace).
In a modern compiler, using
const int MAX_LIMIT = 100;
or
static const int MAX_LIMIT = 100;
is also likely to be just as efficient (no space or time
overhead) as a define.
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form