Why use flags+bitmasks rather than a series of booleans?

后端 未结 10 2094
猫巷女王i
猫巷女王i 2021-02-05 03:29

Given a case where I have an object that may be in one or more true/false states, I\'ve always been a little fuzzy on why programmers frequently use flags+bitmasks instead of ju

10条回答
  •  不知归路
    2021-02-05 03:59

    • Easy setting multiple flags in any order.

    • Easy to save and get a serie of 0101011 to the database.

提交回复
热议问题