Skip to content

Instantly share code, notes, and snippets.

@littleblacklb
Created August 1, 2021 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save littleblacklb/0d42b2930d1a055fc0fb50bc3aa0f20d to your computer and use it in GitHub Desktop.
Save littleblacklb/0d42b2930d1a055fc0fb50bc3aa0f20d to your computer and use it in GitHub Desktop.
&& and & in if condition test
#include <iostream>
using namespace std;
bool b = false;
bool modifyB2True() {
b = true;
return true;
}
/**
* & and && test
*
* author: littleblackLB
*/
int main() {
bool a = false;
if (a & modifyB2True()) { // b -> rtn: true
}
// if (a && modifyB2True()) { // b -> rtn: false
// }
cout << b << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment