Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
description:
If the first operand to the logical AND operator evaluates to false the second operand is guaranteed not to evaluate. Note: the logical OR operator is guaranteed not to evaluate the second operand if the first operand is true. Note: for the logical AND and OR operators, all side effects of the first expression, except for destruction of temporaries, happen before the second expression is evaluated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
int main(int argc, char** argv)
{
int x = 0;
int y = 0;
if (x++ && y++)
{
y += 2;
}
std::cout << x + y << std::endl;
return 0;
}
Enter to Rename, Shift+Enter to Preview
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content