Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How convert int to enum value c++

Tags:

c++

enums

How can I do it

int k = 23;
enum stat_t {
    first = 0,
    second,
    last = k 
};

May be you know how can I do it?

like image 662
YaroslvaV Avatar asked Nov 27 '25 04:11

YaroslvaV


1 Answers

Use const.

int const k = 23;
enum stat_t {
    first = 0,
    second,
    last = k 
};
like image 129
Christian Hackl Avatar answered Nov 28 '25 19:11

Christian Hackl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!