Storing path from A*, using operator::new with boost::multi_array

I'm trying to use dynamic memory allocation for the first time. I want to
allocate memory for a 2 dim dynamic array, to store paths from an A*
function. I think the array for the job is boost::multi_array.
Problem I have is seem to be able to allocate the memory but i can't change
or access any of the elements.
#include <iostream>
#include "boost/multi_array.hpp"
typedef boost::multi_array

Try: (*A)[1][1] = 2; and std::cout << (*A)[1][1] << std::endl; -- View this message in context: http://boost.2283326.n4.nabble.com/Storing-path-from-A-using-operator-new-wi... Sent from the Boost - Users mailing list archive at Nabble.com.

Sladey wrote
Problem I have is seem to be able to allocate the memory but i can't change or access any of the elements.
#include <iostream> #include "boost/multi_array.hpp"
typedef boost::multi_array<int, 2> array_type;
int main() { array_type *A = new array_type;
A->resize( boost::extents[2][2] );
A[1][1] = 2;
std::cout << A[1][1] << std::endl;
delete A;
return 0; }
Try: (*A)[1][1] = 2; and std::cout << (*A)[1][1] << std::endl; Dan Searles -- View this message in context: http://boost.2283326.n4.nabble.com/Storing-path-from-A-using-operator-new-wi... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (3)
-
Dan Searles
-
MrDanS
-
Sladey