将指针转换为多维数组
Casting pointer to multidimensional array
如何将指针转换为多维数组?
例如float*
到 float[][100][100]
?
float* f1(); // returns allocated memory (with data), suitable for processing by f2
void f2(float in[][100][100]);
float* p = f1();
f2( ???CAST??? p);
虽然这样做通常很危险,但如果您真的想这样做,可以使用 reinterpret_cast
:
f2( reinterpret_cast<float(*)[100][100]> (p) );
如何将指针转换为多维数组?
例如float*
到 float[][100][100]
?
float* f1(); // returns allocated memory (with data), suitable for processing by f2
void f2(float in[][100][100]);
float* p = f1();
f2( ???CAST??? p);
虽然这样做通常很危险,但如果您真的想这样做,可以使用 reinterpret_cast
:
f2( reinterpret_cast<float(*)[100][100]> (p) );