Error when trying to use a ternary operator in C?

Either do this: if (chkSelected. Checked) chkSelected. Checked = false; else chkSelected.

Checked = true or this: chkSelected. Checked = chkSelected. Checked?

False : true Or abandon the check and do this: chkSelected. Checked =!chkSelected.Checked.

Either do this: if (chkSelected. Checked) chkSelected. Checked = false; else chkSelected.

Checked = true; ...or this: chkSelected. Checked = chkSelected. Checked?

False : true; Or abandon the check and do this: chkSelected. Checked =!chkSelected.Checked.

I'll take door number two! That looks like something I'd understand when reading further down the line. Thanks for the help!

– delete Nov 29 '10 at 12:53 +1 Num 2 ftw..... although Num 3 is quite smart :) – Dal Nov 29 '10 at 16:42.

Write this as chkSelected. Checked =!chkSelected. Checked instead.To rewrite your exact example, it get's messy like this: chkSelected.

Checked = (chkSelected. Checked)? False : true; The?

: operator returns, in this case, either trueor false. It cannot perform assignment.

You're using assignment instead of comparison, and you don't need an if there. In fact, it isn't too clear what your intent is, but I'd guess it is: chkSelected. Checked =!chkSelected.Checked.

Why not do: chkSelected. Checked =!chkSelected. Checked; Also, it does not compile, because of the if you put in front of it.

Remove that and it will work as well!

I think you mean: chkSelected. Checked=(chkSelected. Checked?

False : true) which can be shortened to: chkSelected. Checked=!chkSelected.Checked.

Because you have to use like a assignation: chkSelected. Checked =(chkSelected. Checked?

False : true); Ternary operator is used like a assignation But here It is not really a good idea to do that here and do chkSelected. Checked =!chkSelected. Checked; Shorter way..

B=a:b) evaluates to an rvalue which you try to assign with be which results in an error. Trying to assign an rvalue is an error. If it is not parsed that way, then its simply a syntax error.

Because the grammar of C does not allow a compiler to parse the code as above. But what you've written (the original code) is correct as C++. Here the grammars of C and C++ differ a lot.

And because of that difference you see both languages treat the expression differently. That is, the conditional expression in C++ is different from the conditional expression in C . E = a E = ((a Which is a valid expression.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions