In my class I defined an enum like this:
class myClass
{
public:
enum access {
forL,
forM,
forA
};
typedef access AccessType;
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.