I'm just wondering if it's possible to allocate a matrix with the "new" command in any way like this:
matrix=new float [size][size];
I've tried most things, and can't find it anywhere on the net.
Leiken
I'm just wondering if it's possible to allocate a matrix with the "new" command in any way like this:
matrix=new float [size][size];
I've tried most things, and can't find it anywhere on the net.
Leiken
Code:int** matrix=new int*[size]; for(int i=0;i<size;i++) matrix[i]=new int[size];
it's possible.
float ** maze;
maze = new float*[sizeA];
for(int i = 0; i < sizeA; i++)
{
maze[i] = new float[sizeB];
}
where sizeA and sizeB are integers. Also look up how to delete the dynamically memory so declared to prevent memory leaks in your program.
The answer to your question: No.
You have to use the code that Sorensen gave you.
Deleting this memory is as simple as
delete[] maze;
The rest should be automatically done when you call this.
>Deleting this memory is as simple as delete[] maze;
After looping through and deleting the indivdual pointer to floats using a similar method to the allocation.
Code:for (i=0;i<size;i++) delete [] maze[i]; delete [] maze;
Thanks loads guys! I'm happy now..