最近我想将一些代码从opencv转换为c#。但我在C++中声明动态数组时遇到了一些问题。将C++代码转换为c#声明数组
int* memorySteps = 0;
CV_CALL(memorySteps = new int [ 10*sizeof(memorySteps[0]) ]);
我想将它转换为普通的c#int数组。问题是长度。在C++中,上面的声明似乎是编译器将创建一个包含40个int元素的数组(size of memorySteps [0]的大小为4,长度为4个字节)。我的理解是否正确?然而,它没有任何意义,因为实际上在算法中我只需要一个10个int元素的数组。因此,谁能给我一个提示这是正确的以下(在C#),或任何人都可以告诉我其他的例子:
int[] memorySteps =new int [10*sizeof(int)];
或
int[] memorySteps =new int [10];
欢迎来到寻找别人代码中的错误的奇妙世界! – dasblinkenlight 2012-03-08 14:41:40
是的,那C++代码没有意义。 – 2012-03-08 14:42:09