trying to remove item from an array
this is a function that should remove an integer from an array but when i run it, it will remove the integer but the array will remain the same size. do i have an error im not seeing.
Code:
// Method that takes an int from the bag making it one size smaller
// int refers to its location in memory using a zero index
void Bag::take(int location)
{
cout<<"TAKING" << endl;
int new_maxsize = maxsize - 1;
int *temp_array = new int[new_maxsize];
int second_half = location + 1;
for (int index = 0; index < location; index++)
{
temp_array[index] = p[index];
}
for (int index = location; index < new_maxsize; index++)
{
temp_array[index] = p[second_half];
second_half++;
}
maxsize = new_maxsize;
p = temp_array;
currentloc = new_maxsize;
}