C++ Question

Posts 1–7 of 7 · Page 1 of 1
C++ Question
what is this mean ? in C++ for example

line <line2 ? line : line1;
Code:
a<=b?cout<<"a is less then b":cout<<"b is less then a";
Can also be written as:
Code:
if(a<=b)
{
    cout<<"a is less then or equal to b";
}
else
{
    cout<<"b is less then a";
}
I use it to shorten stuff up
Learn C++ get a book for it or read tutorials.
Quote Originally Posted by systemfiles View Post
Learn C++ get a book for it or read tutorials.
Yeh that was a lot of help system >_>...

Anyway its what HD said. Just a shortened version of the if else statement...

[php]comparison1 < comparison2 ? Execute_If_True : Execute_If_False;[/php]
Quote Originally Posted by systemfiles View Post
Learn C++ get a book for it or read tutorials.
dude i read book but sometimes when i get bored of the chapter i skip some pages and when i got to a code i saw that thing.

anyways thx guys i researched online and got it.
why doesn't this work???

Code:
val1<val2?return (val1):return (val2);
Quote Originally Posted by lalakijilp View Post
why doesn't this work???

Code:
val1<val2?return (val1):return (val2);
Try doing it this way. I just realised the shorthand version can only pass a values sort of forgot about that :l. So like this:

Code:
return (val1<val2) ? val1 : val2;
Posts 1–7 of 7 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Talk with us