Let's get some things out first; using namespace std;
, return 0;
in main
and C-style arrays are discouraged in modern C++. Rewriting the code to utilize recommended style yields this:
#include <iostream>
#include <array>
int func(....);
int main(){
std::array<std::array<char, 10>, 10> arr;
...
}
The type is tedious to write, so we can make an alias:
template<typename T>
using TenByTenArray = std::array<std::array<T, 10>, 10>;
Now the declaration becomes more readable:
TenByTenArray<int> arr;
And so our function can now take a reference to that type easily:
int func(TenByTenArray<int> & arr) {
// use arr to modify it
}
Making an example complete program:
#include <iostream>
#include <array>
template<typename T>
using TenByTenArray = std::array<std::array<T, 10>, 10>;
void func(TenByTenArray<int> & arr) {
for (int x = 0; x < 10; x++) {
for (int y = 0; y < 10; y++) {
arr[x][y] = x + y*100;
}
}
}
int main(){
TenByTenArray<int> arr;
func(arr);
std::cout << arr[4][2] << std::endl;
}