Ja nun noch einmal zu der Diskussion um die Verwendung von
const und
#define.
Es gibt ein paar Unterschiede, die sich doch bemerkbar machen.
Anstatt diese hier vielleicht ein bisschen ungenau und undeutlich aufzuführen, hier mal zwei Links zu ähnlichen Diskussionen:
http://www.thescripts.com/forum/thread134615.html
http://www.dsprelated.com/showmessage/25035/1.php
Diese beiden Diskussionen kannte ich schon. Daher kann ich hier mal zwei "Schlüsselstellen zitieren":
MACROS ARE EVIL
Don't use macros.
There's is absolutlely no need for them in C++.
Macro constants -> const global variables
Macro functions -> inline functions
Pretty much. The difference (semantically) is that the const has an
address which can be taken with the &() operator and the #define doesn't,
and so it can't.
Similarly, you can test the value of the #define with other pre-processor
constructs (#if, #ifdef), and you can't do that for the const.