Changing size of a dynamically allocated matrix
Posted
by
user1309174
on Stack Overflow
See other posts from Stack Overflow
or by user1309174
Published on 2012-04-02T22:53:52Z
Indexed on
2012/04/02
23:30 UTC
Read the original article
Hit count: 181
Trying to re-size the shape matrix dynamically. This is part of a drawing program where _capacity is the number of shapes drawn on a frame.
Get the error in new Shape about _capacity
saying expression needs to have a constant value.
void ShapeStore::Grow(int minimumCapacity)
{
_capacity = max (minimumCapacity, 2 * _capacity);
if (_capacity)
{
Shape ***newData = new Shape[_frames][_capacity]; //figure out this
int i;
for (int k = 0; k < _frames; k++)
for (i=0;i<_count;i++)
newData[k][i] = _data[k][i];
delete [] _data;
_data = newData;
} //*/
}
© Stack Overflow or respective owner