开发者

enum flags with name

开发者 https://www.devze.com 2023-01-14 05:43 出处:网络
I\'m going to use enum flags for options to initialize my class. The enum is: namespace MCXJS { enum VARPARAM

I'm going to use enum flags for options to initialize my class. The enum is:

namespace MCXJS
{
    enum VARPARAM
    {
        STATIC = 1,
        CONST = 2
    }

    //other things
}

If I'm right, in this case, to check for STATIC I need to do this:

if (param & MCXJS::VARPARAM::STATI开发者_C百科C) //...

I know to do it this way:

if (param & MCXJS::STATIC) //...

i need to delete enum name. But it that really necessary? Cannot I use enum values of named enum without typing its name everywhere?


Huh? You don't need to prefix it with the enumeration name. That's only needed for C++0x enum class scoped enumerations.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号