I'm learning Visual C++ using MFC and I need to create a dynamic int array without worry about memory location. The array size will be increasing during the run time.
int myArray[5]; // I want to change this as a dynamic array
int counter = 0;
int currentValue;
... more Code
void CScribbleView::OnLButtonUp(UINT, CPoint point)
{
myArray[counter] = currentValue;
counter++;
currentValue = 0;
... more Code
}
new[]anddelete[]. See this tutorial. But I suggest using an existing array collection orstd::vector.std:vectoris definitely a better alternative toCArray.CArrayis usually a better choice, as it comes with serialization support built in.