C++ meaning |= and &=

后端 未结 7 1480

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:33

    These are bitwise AND and OR operations. The lines you mentioned are equivalent to:

    m_controlState = m_controlState | TDC_LEFT;
    m_controlState = m_controlState & ~TDC_LEFT
    

提交回复
热议问题