Dynamic 2D Array

Hello,
I have a dynamic 2D array that I'm decreasing size by one by a function. It may not always be the last row/column being deleted. It could be one in the middle of the array. I'm not sure how to copy over the elements in the old array to the new one.

For example, say I have a 2D array below and want to delete column 3.
0 1 |0| 2
1 0 |1| 3
0 1 |0| 2
2 3 |2| 0

How do I copy over the elements then?

Here's what I have so far.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
vertexCount = vertexCount - 1;

arrDec = new float*[vertexCount];
for (i = 0; i < vertexCount; i++)		//allocate space of new size
{
	arrDec[i] = new float[vertexCount];
}

//copy to new from old

for (i = 0; i < vertexCount + 1; i++)		//delete old
{
	delete[] adjacencyMatrix[i];
}
delete[] adjacencyMatrix;

vertices.erase(vertex);
adjacencyMatrix = arrDec;	//update pointer 
for( .... )
std::swap( arr[i][2], arr[i][3]) // <algorithm>

then,
http://www.cplusplus.com/forum/beginner/148570/
And for the rows I could just switch around the variable in the array, right?
I could just swap the rows/columns to the outer most row/column and then copy over within the new range.
Topic archived. No new replies allowed.