C++ 运算符(廿四)--按位运算符和赋值运算符结合(^=)、

来源:互联网 发布:mac开机读条一半就黑屏 编辑:程序博客网 时间:2024/06/14 08:41


 ^= 运算符

#include <iostream>using namespace std;bool state = 0;void log(){    cout << state << endl;}void turnOn(){    state ^= 1 ;//等价于 state = (state ==0)?1:0;    log();}int main(int argc, const char * argv[]) {    // insert code here...        int i = 0;    while (i<10) {                turnOn();        i++;    }        return 0;}


0 0
原创粉丝点击