1. whats the point of it? (except it can help debugging abit) where is it really needed?
2. if you create a pointer like this:
'
char const *
'
will the pointer, and not the char become constant?
(maybe this is the wrong place to ask, but whatever..)
"If Darl McBride was in charge, he'd probably make marriage unconstitutional too, since clearly it de-emphasizes the commercial nature of normal human interaction, and probably is a major impediment to the commercial growth of prostitution."
-- Linus Torvalds, December 5th 2003.
(Darl McBride is CEO of The SCO Group)
this place sucks but don't tell anyone, it's our little secret, ok?
const lets you create constants, so that you don't accidentally change things.
char const * means the pointer is constant, but the data it points to can change. const char * means the pointer points to a const char. (e.g. string literals)
just as i thought then... thanks for making it clear to me
"If Darl McBride was in charge, he'd probably make marriage unconstitutional too, since clearly it de-emphasizes the commercial nature of normal human interaction, and probably is a major impediment to the commercial growth of prostitution."
-- Linus Torvalds, December 5th 2003.
(Darl McBride is CEO of The SCO Group)
this place sucks but don't tell anyone, it's our little secret, ok?
Using constants instead of 'variables that don't change' should be faster, too
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
Works in the same way as the #define keyword used by the pre-processor, in that the variable itself doesnt exist when you run the EXE, instead every time the pre-processor sees the keyword it replaces it with the value, and saves that into the EXE instead. Saves in memory and speed.
Mike
"Now I guess we're... 'Path-E-Tech Management'" -Dilbert
because then you can't specify the type of the constant
"If Darl McBride was in charge, he'd probably make marriage unconstitutional too, since clearly it de-emphasizes the commercial nature of normal human interaction, and probably is a major impediment to the commercial growth of prostitution."
-- Linus Torvalds, December 5th 2003.
(Darl McBride is CEO of The SCO Group)
this place sucks but don't tell anyone, it's our little secret, ok?