Similar to #define for constant values (or similar to standard variable declarations), is there a way to define/declare CONDITIONS upfront?
To further explain why this is necessary... In my code, I do an IF statement to test a condition. However, I believe I might change this condition later as my code evolves. Plus this condition might be tested at various points across the code. So it would be nice to declare upfront at the beginning of my code what this condition is (and possibly other conditions).
So, I'm looking for something resembling Code-A, instead of Code-B.
Code-A:
#define ConditionA [a > 20 && a < 30]
...
if (ConditionA) {
// action...
}
is there a way to define/declare CONDITIONS upfront?
The #define statement simply defines a name and a corresponding value. The preprocessor looks for occurrences of the name in the code and substitutes the value in its place, before the compiler runs.
#define ConditionA [a > 20 && a < 30]
defines a name, ConditionA, and a value "[a > 20 && a < 30]". The preprocessor will then change