Flags, enum (C)

后端 未结 6 1493
既然无缘
既然无缘 2021-02-02 14:54

I\'m not very used to programming with flags, but I think I just found a situation where they\'d be useful:

I\'ve got a couple of objects that register themselves as lis

6条回答
  •  余生分开走
    2021-02-02 15:28

    Can't you just set the values in the enum?

    enum {
     TAKES_DAMAGE = 1,
     GRABBABLE    = 2,
     LIQUID       = 4
    }
    

    Afterwards, just perfom bit-wise OR on them.

提交回复
热议问题