Began to study C / C ++, and there you need to know all the logical operations in C ++ (of the type && , *= , etc.), tell me where you can find all the explanations for this and, preferably, with examples and detailed description .
- I'm talking about all the operations and not about things and preferably with an example - Alexey
- logical operations in c ++ only 3, the rest is bitwise, or am I wrong? - Specter
- oneYou will not believe logical - only 3 =) XOR, for example, is already a combination. * = - this is a general multiplication%) - Sh4dow
- If you are talking about operations like * =, + =, - =, / =, etc., then these are not logical operations. - 3JIoi_Hy6
|
1 answer
&& - logical "AND" - true && true => true in other cases false
example 1:
2 двери, если хотя бы одна закрыта вы не можете пройти, если открыты обе, пройти можно | | / / <= ☺ | | example 2:
public bool Condition(bool flag) { return flag; } main() { bool trigger = true; if(Condition(trigger) && Condition(trigger)) { //условие выполняется только в этом случае } } || - logical "OR" - false || false => false false || false => false otherwise true
example 3:
2 двери, если хотя бы одна открыта вы можете пройти, если закрыты обе, пройти нельзя | / | <=☺ / | example 4:
public bool Condition(bool flag) { return flag; } main() { bool trigger = false; if(Condition(trigger) || Condition(trigger)) { //условие не выполняется только в этом случае } } ! - logical "NOT" - !true => false; !false => true !true => false; !false => true
== - logical equality true == true; false == false true == true; false == false
!= - logical inequality true != !true; false != true true != !true; false != true
on Wiki Boolean operation
|