#define dItemName L"CellPhone"
#define
is a preprocessor instruction that defines a macro. In your case macro dItemName
with value L"CellPhone"
.
Macros are bad mostly because they are processed before the actual code is. This means that they aren't subjected to scopes and to the rules of C++ syntax. If you've got a variable somewhere called dItemName
, things won't probably work: you'll get hard-to-understand compilation errors due to that.
The solution is to declare dItemName
as a variable (in this case a const
variable).
Pointing to define doing what they where invented for as a failure is - well blaming a knife for cutting.
If you dont not properly Name your defines with UPPERCASE_NAMES you will have troubles, but you will have those troubles anyway in C if you can not self-discipline your working style.
You can not use const to generate dynamically rearranging systems, so its not suited for any embedded Application that is tailored pre-compile to usage.Const can only be assigned pre-evaluation constants, so not even other const Expressions.
Just because a Tool doese not bow to the OO-Paradigm its does not suddenly become useless. Const is not equal replacement regarding functionality.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With