My program treats matrixes reading them from a file. Their size is given in the beginning of the file. How to allocate memory for the matrix?
1
Expert's answer
2010-08-03T11:22:19-0400
For this you need to place your matrix not in the stack, but in a heap. To allocate memory for objects in the heap, use the operator new. You can allocate memory for the matrix by several blocks. To do this you need to allocate memory for an array of string pointers. Then for each pointer using the new operator allocate memory for the string. The syntax for using such a matrix is similar to the syntax of regular matrix:
Objects, memory for which you have selected by the new operator does not remove themselves. You must call the delete operator to free the memory. You can also use operator delete[] to delete an array.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment