C++ meaning |= and &=

后端 未结 7 1470

I have a part of code that contains the following functions:

void Keyboard(int key)
{
    switch (key) {
    case GLFW_KEY_A: m_controlState |= TDC_LEFT; bre         


        
7条回答
  •  南方客
    南方客 (楼主)
    2020-12-20 08:20

    x |= y specifically turns on (sets to 1) those bits in x present in y, leaving all the others in x as they were.

    x &= ~y specifically turns off (sets to 0) those bits in x present in y, leaving all the others in x as they were.

提交回复
热议问题