|
-
Feb 20th, 2001, 04:39 PM
#1
Thread Starter
Addicted Member
What does this code do?
Im lost on the ? and : signs?
Code:
return(num1>num2 ? num1 : num2);
-
Feb 20th, 2001, 04:46 PM
#2
Monday Morning Lunatic
The ?: operator is merely shorthand:
Code:
string x;
int y = 4
x = ((y > 4) ? "Y greater than 4" : "Y not greater than 4");
Here's the syntax:
Code:
result = (comparison) ? true-result : false-result
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Feb 20th, 2001, 04:48 PM
#3
Frenzied Member
If num1>num2 then num1 is returned else if num1<num2 then num2 is returned.
That means thet if the expression is true the first value is returned else the second is retuned.
-
Feb 20th, 2001, 04:50 PM
#4
Frenzied Member
-
Feb 20th, 2001, 04:52 PM
#5
Monday Morning Lunatic
Hehe n/p 
<<< burns back from holiday to answer questions
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|