|
thanks redhead that is a good point ..
so you are saying that it is just the equivelent to:
if(condition 1)
{
expression1;
} else {
expression1;
}
and that is not saving you if/else statements, .. it's just saving you 1 if else statement.
... i guess it's useful as shorthand .. also. you can use it even in your cout statement or defining a variable.. i do like that.
i.e. variable = (condition1) ? expression1 : expression2;
or
cout << "the ternary result is " << ((condition1)?expression1:expression2);
i was trying to get it to work in the cout statement for a while the other night, but then i realized you must have the surrounding " ( ) " to make it work.
Last edited by sde; 06-15-2002 at 09:03 AM.
|