I have the following piece of code
mystack.empty() ? return 1 : return 0;
which looks perfect from the syntax point of view but whenever I try to run it throws an error saying
[Error] expected ':' before 'return'
and
[Error] expected primary-expression before 'return'
Do ternary operator don't work with return statements or is there something wrong with the code? And I guess the code is self explanatory.
Thank you.
Aucun commentaire:
Enregistrer un commentaire