Question: PROGRAM SPECIFICATION For this program, we are going to expand a standard array by dynamically allocating a new one with a larger footprint. The program
PROGRAM SPECIFICATION
For this program, we are going to expand a standard array by dynamically allocating a new one with a larger footprint. The program will use a function that accepts an integer array and the size of the integer array, and then increases it to hold one more item. It shifts all of the original arrays values over by one into the new dynamic array, and sets the first element to the value of zero. When the creation and move are complete, this function returns a (smart) unique pointer pointing to the new dynamic array back to the calling program (main).
The program will use the declarations for the array and pointer (in main) as follows:
const int SIZE = 5;
int myNumbers[SIZE] = {18, 27, 3, 14, 95};
// Define a unique_ptr smart pointer, pointing
// to a dynamically allocated array of integers.
// A unique_ptr is a small, fast, move-only smart
// pointer usually used for managing resources
// with exclusive ownership semantics
unique_ptr
Your program should display 0 18 27 3 14 95 after the element shift function does its work.
The Functions (in separate files):
The first function should dynamically allocate an array to hold the additional element. It should then copy each element into the new dynamic array. It will return the smart pointer. IMPORTANT: Make sure that your function creates the dynamic array using the unique pointer.
A function to display the elements in the array (called before and after). If you can make this function work for the old and new, bravo. If you need to create two separate functions to print both the old and the new arrays, thats fine. Know that you can get by with just using one.
Dont forget to use separate functions. Remember for our practice we are placing functions in dot hpp files. Use the include guards in the functions.
Make sure that your programs follow good documentation standards and follow the requirements for assignments. Reference the rubric standards on Springboard. Note functions and data validation are now required. Do not use using namespace std;. For this assignment you are required to submit separate compilation files (place your functions into .hpp files).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
