如何通过它的号码访问枚举成员 [英] how to access to enumeration member via it's number
问题描述
您好,
我必须关注此问题。
基于枚举声明类型:
"
enum TpAddressPlan {
P_ADDRESS_PLAN_NOT_PRESENT = 0,
P_ADDRESS_PLAN_UNDEFINED = 1,
P_ADDRESS_PLAN_IP = 2,
P_ADDRESS_PLAN_MULTICAST = 3,
P_ADDRESS_PLAN_UNICAST = 4,
P_ADDRESS_PLAN_E164 = 5,
P_ADDRESS_PLAN_AESA = 6,
P_ADDRESS_PLAN_URL = 7,
P_ADDRESS_PLAN_NSAP = 8,
P_ADDRESS_PLAN_SMTP = 9,
P_ADDRESS_PLAN_MSMAIL = 10,
P_ADDRESS_PLAN_X400 = 11 ,
P_ADDRESS_PLAN_SIP = 12,
P_ADDRESS_PLAN_ANY = 13,
P_ADDRESS_PLAN_MIN = 14
};
typedef enum TpAddressPlan TpAddressPlan;
"
函数接收一个对应于枚举的整数
成员我必须转换为成员来填充结构成员
类型TpAddressPlan:
"
this-> msg.CEType_u.msgreq.CERequest_u.qryreq.userID.Pla n =
AddressPlan; // [0-14]
"
我如何为AddressPlan分配枚举值,从
开始'的整数值:种类
??? AddressPlan = TpAddressPlan(i)???
感谢您的帮助!
Hello,
I have to following issue.
A type is declared based on an enum:
"
enum TpAddressPlan {
P_ADDRESS_PLAN_NOT_PRESENT = 0,
P_ADDRESS_PLAN_UNDEFINED = 1,
P_ADDRESS_PLAN_IP = 2,
P_ADDRESS_PLAN_MULTICAST = 3,
P_ADDRESS_PLAN_UNICAST = 4,
P_ADDRESS_PLAN_E164 = 5,
P_ADDRESS_PLAN_AESA = 6,
P_ADDRESS_PLAN_URL = 7,
P_ADDRESS_PLAN_NSAP = 8,
P_ADDRESS_PLAN_SMTP = 9,
P_ADDRESS_PLAN_MSMAIL = 10,
P_ADDRESS_PLAN_X400 = 11,
P_ADDRESS_PLAN_SIP = 12,
P_ADDRESS_PLAN_ANY = 13,
P_ADDRESS_PLAN_MIN = 14
};
typedef enum TpAddressPlan TpAddressPlan;
"
And a function receive an integer corresponding to the enumeration
member that I must convert into the member to fill a structure member
of the type TpAddressPlan:
"
this->msg.CEType_u.msgreq.CERequest_u.qryreq.userID.Pla n =
AddressPlan; // [0-14]
"
How can I assign to AddressPlan the enumeration value, starting from
it''s integer value: kind of
???AddressPlan = TpAddressPlan (i)???
Thanks for your help!
推荐答案
2月20日下午2:18,brarat ... @ gmail.com写道:
On Feb 20, 2:18 pm, brarat...@gmail.com wrote:
您好,
我必须遵循以下问题。
基于枚举声明类型:
enum TpAddressPlan {
P_ADDRESS_PLAN_NOT_PRESENT = 0,
P_ADDRESS_PLAN_UNDEFINED = 1,
P_ADDRESS_PLAN_IP = 2,
P_ADDRESS_PLAN_MULTICAST = 3,
P_ADDRESS_PLAN_UNICAST = 4,
P_ADDRESS_PLAN_E164 = 5,
P_ADDRESS_PLAN_AESA = 6,>
P_ADDRESS_PLAN_URL = 7,
P_ADDRESS_PLAN_NSAP = 8,
P_ADDRESS _PLAN_SMTP = 9,
P_ADDRESS_PLAN_MSMAIL = 10,
P_ADDRESS_PLAN_X400 = 11,
P_ADDRESS_PLAN_SIP = 12,
P_ADDRESS_PLAN_ANY = 13,
P_ADDRESS_PLAN_MIN = 14};
typedef enum TpAddressPlan TpAddressPlan;
Hello,
I have to following issue.
A type is declared based on an enum:
"
enum TpAddressPlan {
P_ADDRESS_PLAN_NOT_PRESENT = 0,
P_ADDRESS_PLAN_UNDEFINED = 1,
P_ADDRESS_PLAN_IP = 2,
P_ADDRESS_PLAN_MULTICAST = 3,
P_ADDRESS_PLAN_UNICAST = 4,
P_ADDRESS_PLAN_E164 = 5,
P_ADDRESS_PLAN_AESA = 6,
P_ADDRESS_PLAN_URL = 7,
P_ADDRESS_PLAN_NSAP = 8,
P_ADDRESS_PLAN_SMTP = 9,
P_ADDRESS_PLAN_MSMAIL = 10,
P_ADDRESS_PLAN_X400 = 11,
P_ADDRESS_PLAN_SIP = 12,
P_ADDRESS_PLAN_ANY = 13,
P_ADDRESS_PLAN_MIN = 14};
typedef enum TpAddressPlan TpAddressPlan;
你不需要C ++中的typedef。
You don''t need a typedef in C++.
和一个函数接收一个对应于枚举
成员的整数,我必须将其转换为成员以填充结构成员
类型为TpAddressPlan:
" ;
this-> msg.CEType_u.msgreq.CERequest_u.qryreq.userID.Pla n =
AddressPlan; // [0-14]
"
我如何为AddressPlan分配枚举值,从
开始'的整数值:种类
??? AddressPlan = TpAddressPlan(i)???
And a function receive an integer corresponding to the enumeration
member that I must convert into the member to fill a structure member
of the type TpAddressPlan:
"
this->msg.CEType_u.msgreq.CERequest_u.qryreq.userID.Pla n =
AddressPlan; // [0-14]
"
How can I assign to AddressPlan the enumeration value, starting from
it''s integer value: kind of
???AddressPlan = TpAddressPlan (i)???
如果你确定我在正确的范围内(0-14)并且值
对应于正确的枚举那么只是使用
AddressPlan = TpAddressPlan(i);
-
Erik Wikstr?m
If you are sure that i is in the correct range (0-14) and the value
corresponds to the right enumeration then just use
AddressPlan = TpAddressPlan(i);
--
Erik Wikstr?m
br ******* @ gmail.com 写道:
我必须关注以下问题。
基于枚举声明类型:
"
enum TpAddressPlan {
P_ADDRESS_PLAN_NOT_PRESENT = 0,
P_ADDRESS_PLAN_UNDEFINED = 1,
P_ADDRESS_PLAN_IP = 2,
P_ADDRESS_PLAN_MULTICAST = 3,
P_ADDRESS_PLAN_UNICAST = 4,
P_ADDRESS_PLAN_E164 = 5,
P_ADDRESS_PLAN_AESA = 6,
P_ADDRESS_PLAN_URL = 7,
P_ADDRESS_PLAN_NSAP = 8,
P_ADDRESS_PLAN_SMTP = 9,
P_ADDRESS_PLAN_MSMAIL = 10,
P_ADDRESS_PLAN_X400 = 11,
P_ADDRESS_PLAN_SIP = 12,
P_ADDRESS_PLAN_ANY = 13,
P_ADDRESS_PLAN_MIN = 14
};
typedef enum TpAddressPlan TpAddressPlan;
I have to following issue.
A type is declared based on an enum:
"
enum TpAddressPlan {
P_ADDRESS_PLAN_NOT_PRESENT = 0,
P_ADDRESS_PLAN_UNDEFINED = 1,
P_ADDRESS_PLAN_IP = 2,
P_ADDRESS_PLAN_MULTICAST = 3,
P_ADDRESS_PLAN_UNICAST = 4,
P_ADDRESS_PLAN_E164 = 5,
P_ADDRESS_PLAN_AESA = 6,
P_ADDRESS_PLAN_URL = 7,
P_ADDRESS_PLAN_NSAP = 8,
P_ADDRESS_PLAN_SMTP = 9,
P_ADDRESS_PLAN_MSMAIL = 10,
P_ADDRESS_PLAN_X400 = 11,
P_ADDRESS_PLAN_SIP = 12,
P_ADDRESS_PLAN_ANY = 13,
P_ADDRESS_PLAN_MIN = 14
};
typedef enum TpAddressPlan TpAddressPlan;
这是不必要的。变量声明中的'enum'是可选的。
That''s unnecessary. ''enum'' in variable declarations is optional.
"
一个函数接收一个对应于枚举
成员我必须转换为成员来填充结构成员
类型TpAddressPlan:
"
this-> msg.CEType_u.msgreq.CERequest_u.qryreq.userID.Pla n =
AddressPlan; // [0-14]
"
我如何为AddressPlan分配枚举值,从
开始'的整数值:种类
??? AddressPlan = TpAddressPlan(i)???
"
And a function receive an integer corresponding to the enumeration
member that I must convert into the member to fill a structure member
of the type TpAddressPlan:
"
this->msg.CEType_u.msgreq.CERequest_u.qryreq.userID.Pla n =
AddressPlan; // [0-14]
"
How can I assign to AddressPlan the enumeration value, starting from
it''s integer value: kind of
???AddressPlan = TpAddressPlan (i)???
这就是你的确切方式。
V
-
请在通过电子邮件回复时删除资金''A'
我没有回复最热门的回复,请不要问
That''s exactly how you do it.
V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask
非常感谢!!!所有。
我写了AddressPlan = TpAddressPlan [i]!!这就是问题!
无论如何,我并不知道AddressPlan = TpAddressPlan(i)将
工作。
非常感谢!
Thanks a lot!!! all.
I wrote "AddressPlan = TpAddressPlan[i]"!! That was the issue!
Anyway, I didn''t knew that "AddressPlan = TpAddressPlan(i)" would
work.
Thanks a lot!
这篇关于如何通过它的号码访问枚举成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!