简体   繁体   English

MFC C ++将枚举值插入CArray

[英]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). 我如何遍历枚举内的值并将它们插入CArray(作为其int)。
OR 要么
How can i determine number of values in a enum. 我如何确定枚举中的值数量。

My goal: From: 我的目标:来自:
enum MyEnum{DISCONNECTED=0,CONNECTED=1); 枚举MyEnum {DISCONNECTED = 0,CONNECTED = 1);
To: 至:
CArray that have 2 entries with the enum ints. 具有2个带有枚举int的条目的CArray。

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. 第二个问题是不可能的,我需要它,因为我有许多项目都使用的通用类,并且由于无法以适当的通用方式将枚举发送给该类,因此我将发送一个与枚举值使用相同规则的CArray。

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 :) 枚举值是常量,因此您可以简单地查看枚举的定义并自己查看值:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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