January 14, 2011
C++ create 2D array
How to create dynamic 2d array in C++ ?
This is a code to create 2D array in C++ :
float **ArrayLib::create2Array_float(int row, int col)
{
int i;
float **out;
out = new float*[row];
out[0] = new float[row*col];
for(i=1; i<row; i++)
{
out[i] = out[i-1] + col;
}
return out;
}
If you want to remove or free array 2D, you can use this code :
bool ArrayLib::delete2Array_float(float **array)
{
delete [] array[0];
delete [] array;
return true;
}
2 Comments
Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://accounts.binance.bh/register/person?ref=IXBIAFVY
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?