using enum says invalid conversion from 'int' to 'type'

后端 未结 4 1648
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 02:51

In my class I defined an enum like this:

class myClass 
{
 public:
    enum access {
      forL,
      forM,
      forA
    };
    typedef access AccessType;
            


        
4条回答
  •  孤独总比滥情好
    2021-02-05 03:27

    Enumeration members are backed by integer values but there is no implicit conversion from an integer to an enum type. You need to use an explicit cast if you really want to write it like this:

    ob->aType = static_cast(0);
    

提交回复
热议问题