This Personally, I preprocessor hate, so I always want to go with constants. The main advantage of #define is that it requires no memory to store in your program, as it is actually just replace some text with a literal value it also benefits , There is no way that it can be used for any integer value without generating this warning. The benefits of "constant" S. are that they can be scoped, and they can be used in situations where an indicator of an object has to be passed. I do not know what you are doing with the "stable" part though, if you are declaring globally, then I will put it in a genetic naming place rather than using static. For example, static constant is the best
#define preprocessor to use after
namespace {unsigned const seconds_per_minute = 60; }; Int main (int argc; char * argv []) {...}
Tuesday, 15 July 2014
c++ - static const vs #define -
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment