I'm trying to create a function which will return a pointer to an array, however this causes a massive number of errors, so I'm wondering if it is possible to do this in c++. This is the code I'm trying to use:
[PHP]int *getMatrix(int column, int row){
int sparseMatrix[column][row];
...
return &sparseMatri x[0];
}[/PHP]
I want to be able to use this function to create multiple arrays, however when I try to build the project, the declaration of sparseMatrix[][] gives me an error saying I'm allocating a constant size of 0 to it.
So, is it possible to create a function which can return a pointer to an array, where the array itself was created inside the function?
Or am I trying to make c++ do something that it isn't intended to do?
Thanks for any help!
[PHP]int *getMatrix(int column, int row){
int sparseMatrix[column][row];
...
return &sparseMatri x[0];
}[/PHP]
I want to be able to use this function to create multiple arrays, however when I try to build the project, the declaration of sparseMatrix[][] gives me an error saying I'm allocating a constant size of 0 to it.
So, is it possible to create a function which can return a pointer to an array, where the array itself was created inside the function?
Or am I trying to make c++ do something that it isn't intended to do?
Thanks for any help!
Comment