lundi 2 novembre 2020

What are pros and cons of using &&(and) as an if statement in c++? [closed]

Using the shortcut function of the &&, if the first statement is false, it won't check the second statement. Using this I discovered you can put a regular line of code in the second statement and it basically works like an if function. I'm basically wondering how this would affect the speed of the program, or if it has any other unknown downsides. So far I got Pro: it takes less space in the code. Con: it's harder to read. I was also thinking this is similar to the ? function but without the else condition.

Aucun commentaire:

Enregistrer un commentaire