我对c ++ / cli相当新,我创建了一个自定义类,它有两个2d数组作为属性。我在为这些属性创建get / set时遇到问题。我尝试了几种不同的方法来定义get / set,但还没有成功。任何帮助,将不胜感激。感谢。
public ref class MyClass {
public:
cli::array<bool, 2>^ filled;
cli::array<System::String^,2> ^id;
MyClass() {
filled = gcnew cli::array<bool,2 > (8, 12);
id = gcnew cli::array<System::String^, 2>(8, 12);
for (size_t i = 0; i < 8; i++)
{
for (size_t z = 0; z < 12; i++)
{
filled[(int)i, (int)z] = false; // this line currently gives the error: no instance of function "cli::array<T,rank>::set[with T=bool, rank=2]" matches the argument list
}
}
};
property bool default[int, int]{
bool get(int a, int b) {
return filled[a,b];
}
void set(int a, int b, bool value) {
filled[a,b] = value;
}
}
};