I have this code with function which takes two-dimensional array by reference and its bounds by template as an arguments:
#include <stdio.h>
void Foo(); // I need it here
int main()
{
char Space[10][10];
Foo(Space);
return 0;
}
template <size_t rows, size_t cols>
void Foo(char (&array)[rows][cols])
{
size_t j;
size_t i;
for (j = 0; j < rows; j++)
{
for (i = 0; i < cols; i++)
{
array[i][j] = '.';
}
}
}
I need to declare this function before main code block, and then define after it. How to do this properly?