need help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kimatib
    New Member
    • Dec 2006
    • 1

    need help

    hey can somebody explain what this declaration means:

    int** mult_matrix(int A[2][2], int B[2][2])

    its thr prototype for a function to multiply 2 matrices..but i dont understand what this declaration of pointers means..
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    int ** is a point to a point to an integer. This is often the base type used when dynamically allocating a 2 dimensioned array of int.

    int A[2][2];

    would be a 2 dimensioned array of integers where each dimension has a size of 2. However you can not declare a array in a parameter list and [] in a parameter list is just another way of specifying a pointer so

    int** mult_matrix(int A[2][2], int B[2][2])

    is equivilent to

    int** mult_matrix(int **A, int **B)

    So this is a function that takes 2 parameters each of which is a pointer to a pointer to int and returns a value that is a pointer to a pointer to int.

    Comment

    Working...