If - or statement help - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: If - or statement help (/thread-4627.html)
If - or statement help - Jones - Jan 8, 2006 07:24 PM
I was just trying to write my own header file when I realized..
I'd forgotten how to do an if - or statement!!
So I googled up three different tutorials, but none of them mentioned if-or!
So... can somebody tell me?
If - or statement help - kodex - Jan 8, 2006 08:05 PM
"||" means Or, so
if (statement1) || (statement2)
will return true if either one are true
if (statement1) && (statement2)
will return true if only both are true
Or you could be talking about
else if (statement2)
Its kinda hard from your post to determine what you are asking for
If - or statement help - longjumper - Jan 8, 2006 08:55 PM
Er, slight typo there kodex.
Your entire if statement should be within paranthesis itself.
If - or statement help - kodex - Jan 8, 2006 09:11 PM
Woops yea it from an old habit of mine I inclose all statements in ()
ie: if ((Statement) || (statement2))
Thanks for catching it =)
If - or statement help - Jones - Jan 8, 2006 09:16 PM
Ah yes, kodex the if (blah || blah2) was what I meant.
Heh, I kept trying to just writw in "or".
If - or statement help - skyhawk - Jan 9, 2006 11:54 AM
Jones Wrote:Ah yes, kodex the if (blah || blah2) was what I meant.I believe you can write "or" too.
If - or statement help - ThemsAllTook - Jan 9, 2006 12:00 PM
skyhawk Wrote:I believe you can write "or" too.
Only if you're using C++. In C, you'd have to do this:
If - or statement help - zKing - Jan 9, 2006 12:41 PM
What?!? Did they add an "or" keyword to C++?!? That'd be news to me.
Or is that a non-standard extention of XCode?
If - or statement help - seven - Jan 9, 2006 07:03 PM
News to me too.
If - or statement help - akb825 - Jan 9, 2006 07:18 PM
It is actually part of standard C++. Here's a list of operators that have keywords associated to them in C++:
and, and_eq, bitand, bitor, compl, not, or, or_eq, xor, xor_eq, not_eq
If - or statement help - zKing - Jan 10, 2006 12:14 AM
Dang, just did some research on this. Sad to say I've been using C/C++ professionally for quite a while now (early 90's) and I haven't run into this before.
For those interested: look up ISO 646. Basically its an alternate international encoding of ASCII and its missing some important chars, so these key words were intended to overcome that limitation.
And there was a time where I was known as a C++-syntax-know-it-all. *sigh*
Pretty cool tho, always nice to learn a new 'trick'
If - or statement help - Chris Ball - Jan 18, 2006 12:04 AM
Doesn't he mean the
kind? He said it was for a header.
If - or statement help - akb825 - Jan 18, 2006 12:12 AM
He said it answered his question. Besides, he said he realized it when writing a header, not it was needed for the header. (and header doesn't mean that he'd be using macros)