Checkpoint 3, Problem 2 (Bonus)

Create a function called pushBack that works as shown below:

int main() {
  int *array = new int[3] {4, 2, 9};
  pushBack(&array, 3, 24);
  for (int i = 0; i < 4; ++i) {
    std::cout << array[i] << "\n";
  }
  return 0;
}

Program output:

4
2
9
24

pushBack parameters:

  1. A pointer to a heap array
  2. Current size of the heap array
  3. New int to add to the end of the heap array

Hint: pushBack will look something like this:

void pushBack(int **array, int currentSize, int newElement) {

}