enemarations vs #define

Status
Not open for further replies.

naresh850

Full Member level 3
Joined
Jun 9, 2006
Messages
157
Helped
6
Reputation
12
Reaction score
4
Trophy points
1,298
Activity points
2,249
Hi,

can anybody tell me which is used better for constants
enemarations or #define
 

Normally Enums are preffered. they more more maintainable in the long run...
 

First, macros(# define) don't observe the usual scope rules. If you declare a macro in a local scope, don't expect it to stay there. Second, some compilers don't preserve macro names for use by symbolic debuggers.

Avoiding macros leaves you with a choice of enumeration...
 

#define, the problem is its not type safe. thatz one of the major reason why enumeration would be preffered out of these 2
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…