#ifdef water
#else
#endif
----
or do I need to use:
#ifdef water
#endif
#ifndef water
#endif
Is this valid c++ code using flags?
Either is fine depending on what you are trying to accomplish. It is the logic of your intention that matters.
Note that you can combine things like a regular if statement, including nesting if appropriate. E.G.
#ifdef WATER
#ifdef BOTTLED
....
#ELSE
#DEFINE TAP
#ENDIF
#ENDIF
Reply:Either one should work. Stylistically, I'd prefer the first because it explicitly ties the two alternatives together. There isn't that few seconds of internalization (or the lack of it) realizing that the second #ifdef is the opposite of the first.
Hope that helps.
online florists
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment