Using pointers, how would you declare a dynamic double array to the effect of:
int matrix = new int[var][var];
where var is the size of the array.
??
Using pointers, how would you declare a dynamic double array to the effect of:
int matrix = new int[var][var];
where var is the size of the array.
??
"The mind, like a parachute, only functions when open."
It's quite similar to what you do to unidimensional arrays. But with a slight "problem":
The problem as you can see is you can only specify the first dimension as a variable. All subsequent dimensions must be constants.Code:int* matrix=0; //.. get the dimension from user input or processing (dim1) if(!(matrix = new int[dim1][const])) { cout << endl << "Memory allocation failed."; exit(1); }
Also don't forget that no matter the number of dimensions, the delete statement only has one pair of square brackets:
delete [] matrix;
Regards,
Mario Figueiredo
Using Borland C++ Builder 5
Read the Tao of Programming
This advise was brought to you by the Comitee for a Service Packless World
Yes... that was the problem I was facing. For anyone who's interested in the solution the answer is here:
http://www.cprogramming.com/cboard/s...c+double+array
"The mind, like a parachute, only functions when open."
He! I was finding it strange someone like you making such a simple question.
Sorry for misreading your question
Regards,
Mario Figueiredo
Using Borland C++ Builder 5
Read the Tao of Programming
This advise was brought to you by the Comitee for a Service Packless World
No prob Mario, you helped me realize that conventional methods weren't going to work. My thanks.
"The mind, like a parachute, only functions when open."