【发布时间】:2015-12-18 17:25:30
【问题描述】:
以下工作正常:
public value struct Foo {
Platform::String^ Name;
Platform::String^ Type;
};
但是,当我尝试如下添加Platform::Array<double>^ 时,我会收到一条错误消息。
public value struct Foo {
Platform::String^ Name;
Platform::String^ Type;
const Platform::Array<double>^ Value;
};
错误信息:
signature of public member contains invalid type 'const Platform::Array<double,1> ^
我也试过这个const Platform::Array<Platform::String^>^ Values。但我会有类似的错误信息:
signature of public member contains invalid type 'const Platform::Array<Platform::String ^,1> ^'
这是什么意思?我该如何解决这个问题?
编辑:在这种情况下必须使用class,因为value struct 只能包含基本数字类型、枚举类或Platform::String^ 作为字段。
public ref class Foo sealed {
property Platform::String^ Name;
property Platform::String^ Type;
property Platform::Array<Platform::String^>^ Values;
};
【问题讨论】:
-
你见过this answer吗?
-
显然值类型的结构不能使用泛型数组。
标签: c++-cx