Is it possible to express the cases using the conditional operator? For Example :
if(rval==1)
DO THIS 1;
else if(rval==2)
DO THIS 2;
else if (rval ==3)
DO THIS 3;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t. What you have there looks like a use-case for a
switch-statement:Edit I was over-eager here. As @Luchian Grigore points out in the comments, you can do this (as he demonstrates in his answer). Note that this is also well defined for cases where one or both expressions are of the type
void, as specified in §5.16/2 [expr.cond]: