Returning value in conditional operator?

You can only have expressions* as the operands of the ternary conditional, not statements. The usual way to say this is.

You can only have expressions* as the operands of the ternary conditional, not statements. The usual way to say this is: return listSize > 0? True : false; or even better, return listSize > 0; or even better, bool isEmpty() { return Node::size() > 0; } *) Since you tagged this as both C and C++, know that there is a subtle difference between the admissible expressions in the two languages.

Thanks that you mentioned the difference. As it was just a snippet I thought it would be better to tag both languages. – Akito Aug 12 '11 at 21:25 The last one may look good.

But when you enter debug time you will wish you had assigned the result to a temporary before returning so that it is east to inspect. – Loki Astari Aug 12 '11 at 22:35.

The ternary operator (?:) is not designed to be used like that. You have a syntax error. Try this instead: return (listSize > 0).

Nice, simple and short. Thanks :) – Akito Aug 12 '11 at 20:50.

Unless you have a deeper reason for doing this that I am missing, you should just return (listSize > 0);.

Nice, simple and short. Thanks :) – Akito Aug 12 '11 at 20:54.

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