   double **d dynamic allocation c++
  Hello,Im feeling a little bit stupid.How do you allocate a 2d array of size mxn in c++? The only way I can do it is by using malloc calls. But your not supposed to use malloc calls in c++...How do you do it using new double() ???   
  In C++ std tools are preferred to dynamic memory allocation.For a true 2D array one generally uses Boost::MultiArrayIf you don't want to use boost then you could consider usingstd::vector<std::vector<double> >This is actually a ragged array not a 2D array - but that's what you've asked to create anyway so it might work in your case.If you have a good reason to acually do manual dynamic memory allocation then stop and make sure you really have a good reason to do manual dynamic memory allocation.  If after that you're still sure then you can do one of the following:For a ragged arraydouble ** array = new double*[XSize];for (int i=0; i<XSize; i++){  array = new double[YSize];}and then deletefor (int i=0; i<XSize; i++){  delete[] array;}delete[] array;For a 1D array accessed as a 2D arraydouble * array = new double[XSize*YSize];you can access like so:array[x][y] = array[XSize*y+x];delete:delete[] array;I think all that's right - and if it isn't then it just proves my initial argument - dynamic memory allocation is prone to error and annoying - just use the std containers and boost.   ;  Ok so say I used a vector...Wat is the size of the vector intialised to?Can I just randomly index it where ever I want?;  http://www.cplusplus.com/reference/stl/vector/http://www.cplusplus.com/reference/stl/vector/reserve.html   