C++ meaning |= and &=

后端 未结 7 1467

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

    it's a simple way to set & reset specific bit in a word.

    bitword |= MASK is a shorthand of bitword = bitword | MASK which sets the mask bit

    bitword &= ~MASK clears that bit (check your boolean algebra notebook to see why)

提交回复
热议问题