Conditional operator

This way of using the conditional operator isn't working. What is the appropriate way of doing it?

I guess I am not using the right boolean condition since its not working.

icontition == 1? goto real:goto psuedo;
DONT use gotos.

You've used the operator correctly though. Still, restructure your program with normal if and while loops etc so that you don't have any gotos
The thing is just that the conditional operator expects to RETURN something, which it doesn't do at the moment; goto doesn't return anything. As said, don't use gotos in the first place, they can easily be replaced by scope-safe language constructs like if, else, while, for, do-while and others.
I thought "goto" would be useful for event driven programs which is the reason I am trying to learn it.

How could I incooperate "goto" in this?
goto will only work when inside an if statement, I get it now
In every scenario where goto is used, you can alternatively use a continue, break, for, while, do-while, if, else, switch or some other language construct. This may seem like more of a hassle, but it really isn't. In the end a compiler may see that certain C++ construct can be optimized while goto-statements are pretty general, so that it can't always make such assumptions.

Goto is a statement that was carried over from C, if you wan't to learn C++, don't use it. If you want to learn C, ... well, I wouldn't be able to help you in that case. (I'm not too great at it.)
Topic archived. No new replies allowed.