我需要创建一个LPSTR
列表并将其放在结构的LPSTR
属性中。
typedef struct _wfs_pin_caps
{
...
LPSTR lpszExtra; //This attribute should receive
} WFSPINCAPS, * LPWFSPINCAPS;
我需要这种东西。
WFSPINCAPS PinCapabilities;
list<LPSTR> Keys;
Keys[0] = (LPSTR) "value=key";
Keys[1] = (LPSTR) "value1=key1";
Keys[2] = (LPSTR) "value2=key2";
PinCapabilities.lpszExtra = Keys;
我需要传递带有各种值的列表...
最佳答案
很简单,只需执行此操作
struct _wfs_pin_caps {
// ... other fields ...
std::list<const LPSTR> lpszExtra;
};
list<const LPSTR> &extra(PinCapabilities.lpszExtra);
extra.push_back(TEXT("value1=key1"));
extra.push_back(TEXT("value2=key2"));
// ... more items ...
extra.push_back(TEXT("valueN=keyN"));
阅读有关The
TEXT
macro的信息,所以您根本不会进行那种笨拙的转换,这是错误的BTW。注意:您可能应该改为使用
std::vector
,请阅读其文档以作出决定。关于c++ - 在C++中将列表作为属性传递,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42697631/