returns the address of a dynamic matrix.

Hello everybody ....
i have this Question and i solve it ... but i don't know how can i returns the address of the matrix.

the Question :

Complete the following function that takes 2 integers m and n as parameters. The function defines a dynamic matrix of integers of size mXn, fills the matrix with information from the KB, then returns the address of the matrix.
Note: DO NOT forget to put the returned datatype in the given space(………….)
………………………. allocate (int m, int n) { }


My solution :

int allocate (int m, int n){
cin>>n>>m;
int **a;
a=new int *a[n];
for (int i =0; i<n; i++)
a[i] = new int[m];

for (int i=0; i<n ; i++)
for (int J=0; j<m ; j++)
cin >> a[i][j];
}



i will wait your help :)


An address is the value stored in a pointer. You already have the address of your matrix stored in a pointer, so just return it the same way you would any other value.

Thanks very much :) :)
i have now understood it :)
Topic archived. No new replies allowed.