3
所以我有2个数组都是2维cli :: arrays。 初始化cli :: array的正确语法是什么?我在下面的例子中尝试过,但那不起作用。C++使用CLI数组初始化静态int值
//Cords.h
ref class Cords {
private:
static array<int,2>^ Xcord = gcnew array<int,2>(4,4); // [4][4]
static array<int,2>^ Ycord = gcnew array<int,2>(4,4); // [4][4]
public:
Cords();
static int getX(void);
static int getY(void);
};
int Cords::Xcord[0][0] = 4234; //On these lines is the mistake
int Cords::Ycord[0][0] = 2342; //On these lines is the mistake
.NET数组总是初始化为零。您可以使用“类型初始化程序”来预加载其他值。 –
你能举个例子吗? – delorax
查看MSDN上的示例:https://msdn.microsoft.com/en-us/library/ke3a209d.aspx#BKMK_Static_constructors –