C. Parakh
C. Parakh

Reputation: 79

How do i get value in the enum stored in index xyz in C++

enum testing{a,b,c};
testing eg;
int xyz = 1;

How do i get value "b" using xyz variable? something like eg(xyz)...

Upvotes: 2

Views: 127

Answers (1)

FinnTheHuman
FinnTheHuman

Reputation: 1155

You could just:

eg = static_cast<testing>(xyz);

Upvotes: 3

Related Questions