The problem is that you have not declared col
anywhere. Because of this the compiler will complain because mat
is a parameter, but col
it does not know what it is.
In addition, in C ++, if you want to set the size of the array in the parameter, you have to do it statically. That is, the exact size has to be known at compile time. The reason is that for the compiler to be able to do type checking, it must have full knowledge of the compile-time type, so the type can not depend on something that only exists during execution.
And most importantly: In order for the compiler to be able to calculate how much memory each element will occupy, it will need to know at compile time what size each position of the array parameter occupies. Since the type of the parameter is an array (array of arrays), then the compiler necessarily needs to know the exact compile-time size of all dimensions except the first one.
So, this is not valid here:
int a, b, c;
// Erro, os valores a, b e c não estão disponíveis em tempo de compilação, só em tempo de execução.
void funcaoQualquer(int mat[a][b][c]) {
}
This is true, because the compiler knows exactly what the size of each dimension is:
void funcaoQualquer(int mat[5][5][5]) {
}
This is also valid here. Although the compiler does not know the size of the array as a whole, it knows the size of each element in the first dimension.
void funcaoQualquer(int mat[][5][5]) {
}
Those are not valid here. The compiler has no way of knowing what the size of each element in the first dimension is:
void funcaoQualquer1(int mat[][][5]) {
}
void funcaoQualquer2(int mat[][][]) {
}
void funcaoQualquer3(int mat[5][][]) {
}
void funcaoQualquer4(int mat[5][5][]) {
}
void funcaoQualquer5(int mat[][5][]) {
}