Hi all,
I'm having a little problem with array and some "unqualified-id" problem. I've created gazillions (okay, maybe 80) arrays before but I had never encountered such problem. Especially with static arrays.
#include <stdio.h>
#include <cstdlib>
using namespace std;
int main()
{
// with addition of buffers for 3x3 square mask
// 8x8 original image is now 10x10
int [][] imageSquare = //12
{
{4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
{4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
{4, 4, 4, 4,48, 4, 4, 4, 4, 4},
{4, 4, 4,64,64,64,64, 4, 4, 4},
{4, 4,17,64,64,96,64, 4, 4, 4},
{4, 4, 4,64,85,64,64, 8, 4, 4},
{4, 4, 4,64,64,64,64, 4, 4, 4},
{4, 4,56, 4, 4,23, 4, 4, 4, 4},
{4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
{4, 4, 4, 4, 4, 4, 4, 4, 4, 4}
};
// 3x3 square mask
int [][] squareMask =
{
{1, 1, 1},
{1,-8, 1},
{1, 1, 1}
};
int [][] resultSquare;
resultSquare = new int [10][10];
// just instantiating result arrays
for(int i = 0; i < 10; i++){
for(int j = 0; j< 10; j++){
resultSquare [i][j] = 0;
}
}
//now calculating for 3x3 squre mask
int i,j,m,n,a,b;
for(i = 1; i < 9; i++){ //starting from the original image array
for(j = 1; j < 9; j++)
{
a = i-1;
b = j-1;
for(m = 0; m < 3; m++, a++){
for(n = 0; n < 3; n++, b++)
{
resultSquare [a][b] = resultSquare [a][b] + imageSquare [a][b] - squareMask[m][n];
}
}
}
}
// print out the result
}
the error that I'm getting is
comp.cpp:12: error: expected unqualified-id before '[' token
I googled but I've had not much luck with it. Would someone shed some light as to what I did wrong?