简体   繁体   中英

MFC C++ insert enum values to CArray

How can i iterate over the values inside an enum and insert them to CArray (as their int).
OR
How can i determine number of values in a enum.

My goal: From:
enum MyEnum{DISCONNECTED=0,CONNECTED=1);
To:
CArray that have 2 entries with the enum ints.

Thanks !
The 2nd questions is impossible, I need it because i have generic class that i use for many projects and since i cannot send enum to that class in generic proper way, i will send a CArray that play the same rule as the enum values.

You can't do that, but I don't see why you would need to. Enum values are constants, so you can simply go look at the definition of the enum and see the values for yourself :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM