using enum says invalid conversion from ‘int’ to ‘type’

No, they are stored as integers but they are distinct types (e.g. you can even overload based on the enum type). You must convert explicitly:

myClass ob;
ob->aType = (myClass::AccessType)0;

or ever better write the corresponding named value of the enum:

myClass ob;
ob->aType = myClass::forL;

Or perhaps if you want to use the enum just as a set of integer constants, change the type of the field:

class myClass 
{
 public:
    enum {
      forL,
      forM,
      forA
    };
    int aType; // just stores numbers
};

Conversion from enum to int is implicit.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)