jeudi 30 juin 2016

How to pass a stack matrix by reference in C++

My question is simple, if I have a matrix created on the stack rather than on the heap, such as int matrix[10][10], how can I pass it by reference? Or, pass it in a way that it doesn't pass the whole matrix as argument, but just its pointer or reference, or whatever. I use C++11.

void proc(/*WHAT GOES HERE?*/ matrix, int n){    
    matrix[n-1][n-1] = 7;     
}

int main(){

    int matrix[10][10];     

    proc(matrix, 10);       

    return 0;

}

Aucun commentaire:

Enregistrer un commentaire