There is a two-dimensional array of numbers. Int mass [15] [20] It is necessary to transfer it to a function so that its change in the function is reflected in main. After trying to figure it out, I realized that I needed to somehow pass by reference, but I can’t figure out how.

    1 answer 1

    Convey. Only brackets do not forget:

    #include <iostream> void f(int (& mass)[15][20]) { mass[1][1] = 42; } int main() { int mass[15][20] = { 0 }; f(mass); std::cout << mass[1][1] << std::endl; return 0; } 
    • std :: cout << mass [1] [1] << std :: endl; What is this line for? I tried to run without it, it worked like. - Lera
    • @Lera This is just a result output. If you don't need him, do it without him. - Ainar-G