Reputation: 13
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
}
Upvotes: 1
Views: 1837
Reputation: 671
I think what you are looking for is CArray Class, the changes in your code will be something like:
CArray<int, int> myArray;
int currentValue;
... more Code
void CScribbleView::OnLButtonUp(UINT, CPoint point)
{
myArray.Add(currentValue);
currentValue = 0;
... more Code
}
Upvotes: 3