From: Adam J. <aj...@i-...> - 2007-08-20 16:43:25
|
>>You wrote: >> If i have a declaration like the following >>int **temp; >>we want to create an array of integer pointers of dimension 1 x n and memory must be allocated dynamically. Hmmmm.. I don't know why you would use a pointer to pointers to represent a dynamically allocated 2 dimensional array in C++. This appears that you are using a C-Style implementation. The data structure you are trying to create appears to be a matrix. There are several ways to accomplish this. I will take the C++ route, and use a class with vectors to implement a matrix data structure. That would be the C++ straight forward approach. Within this class you could use templates so you could create a matrix with any C++ native types and not just integers. If you didn't want to do it by hand, the Boost library which I have recommended to a lot of people on this list has it already done it for you. Check out this link: http://www.boost.org/libs/numeric/ublas/doc/matrix.htm -Adam Jones |