-
January 7th, 2010, 07:00 AM
#1
Advantages of using "Const "
Hi,
I know that usage of "const" will replace the traditional macro "#define"
but there are lots of other advantages using the "const" keyword.
can some one explain the advantages of using "Const" over #define with reference "MEMORY CONSUMPTION"
-
January 7th, 2010, 08:07 AM
#2
Re: Advantages of using "Const "
Something declared with const does not change.
If the compiler sees two identical const things, it might save space by having the same location referenced by these two things.
-
January 8th, 2010, 09:47 AM
#3
Re: Advantages of using "Const "
The amout of memory used is the same in both cases (if we're talking about unsigned integers). In either case the compiler will replace all the occurences of the symbol with the number you supplied.
What const offers additionally is the fact that you can set a specific type and size for that value.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|