|
-
Jun 20th, 2006, 06:28 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] #define equivalent
In previous work in C++, I have used the #define preprocessor command to implement simple formulas throughout my code. For a (trivial) example:
#define square(x) = x*x
I want to do something similar (actually all I want is #define NoOfY = NoOfX - 1) to clarify for reading purposes the difference between two different stored variables. The second variable is always relative the the first variable (ie it is always X-1), so I don't want to maintain and update two seperate variables (I think extra variables leaves more scope for bugs and errors), but at the same time I don't want to have every reference to Y being X-1 because its reads easier as Y.
I hope that all makes sense.
Anyway, I tried looking for something similar, and I've seen you can set debug variables in the compiler settings for a project and you can also define things using #const, but both these only seem to be visible to #if statements.
Is there some equivilent I can use to make the code more readable without having to maintain two variables?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|