I have a 256x256 2-dimensional array of floats that I am trying to pass into a function and g++ is giving me the error message: Cannot convert 'int (*)[256]' to 'int**'
. How can I resolve this?
void haar2D(int** imgArr);
int imageArray[256][256];
haar2D(imageArray);
I have tried changing the function parameter to types int[256][256]
and int*[256]
without successs.
The function parameter must be declared as the compiler says.
So declare it either like
void haar2D( int imgArr[256][256] );
or
void haar2D( int imgArr[][256] );
or like
void haar2D( int ( *imgArr )[256] );
Take into account that parameters declared like arrays are adjusted to pointers to their elements.
Or your could declare the parameter as reference to array
void haar2D( int ( & imgArr )[256][256] );
If you don't want to change the function.
void haar2D(int** imgArr);
You can try to change the imageArray.
int **imageArray=new int*[256];
for (int i = 0; i < 256; ++i)
{
imageArray[i] = new int[256];
}
Then
haar2D(imageArray);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With