what is the ? thingy called?
-
Ok, i saw the ? thing used in some code, and i dont know what it does. I tried googling, but, um, i dont know what its called, and you cant google for "c++ ?" very easily. So, what is it called so i can google for it lol. *.* cin >> knowledge;
You mean like:
int foo = (blah == 2) ? 1 : 0;
or something like that? If so, that's a conditional expression, referred to variously as "immediate if", the "ternary operator", the "conditional operator", or simply the "?:" operator. It's basically an "if..then..else" type of expression that returns a value. Users of functional languages are very familiar with doing conditionals like this. - Mike -
Ok, i saw the ? thing used in some code, and i dont know what it does. I tried googling, but, um, i dont know what its called, and you cant google for "c++ ?" very easily. So, what is it called so i can google for it lol. *.* cin >> knowledge;
Search for "ternary operator". It ought to be called a "trinary operator" since it takes 3 arguments, but the incorrect term "ternary" has stuck for whatever reason. --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber CP SearchBar v2.0.2 released
-
Search for "ternary operator". It ought to be called a "trinary operator" since it takes 3 arguments, but the incorrect term "ternary" has stuck for whatever reason. --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber CP SearchBar v2.0.2 released
-
Ok, i saw the ? thing used in some code, and i dont know what it does. I tried googling, but, um, i dont know what its called, and you cant google for "c++ ?" very easily. So, what is it called so i can google for it lol. *.* cin >> knowledge;
Hi, do you mean the ? : operator????:) This is just an abbreviation for an if else statement used in C++. Consider the following for example:
return x = a ? b< c : d > a;
In this case x is either (ba) depending on the programming return value. Hope it helps. Regards. Alex -
ok, so in the example above, it basically means
(if blah == 2) { foo = 1; } else { foo = 0; }
pretty neat...thanks-o. *.* cin >> knowledge;That is correct :) --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber CP SearchBar v2.0.2 released