jeudi 16 juillet 2020

How to assign const enum variable to normal enum variable using C++?

I have two enum's like as shown below:

typedef enum {
    NONE = 0,
    test1,
    test2
} TestType;

enum class type
{
    zero = 0,
    one,
    two,
    three
};

When I am assigning one enum to another like as shown below:

const type f_eType;
TestType l_etestType = f_eType;

I am getting the below error: a value of type "type" cannot be used to initialize an entity of type "TestType"

could someone please help me how to resolve this error without using static_cast

Aucun commentaire:

Enregistrer un commentaire