Question: 3460:209 Assignment 9-B Assignment9-B: The Element Shifter The purpose of this assignment is to help gauge your skills in writing small programs that involve pointers.

 3460:209 Assignment 9-B Assignment9-B: The Element Shifter The purpose of this

3460:209 Assignment 9-B Assignment9-B: The Element Shifter The purpose of this assignment is to help gauge your skills in writing small programs that involve pointers. The program also contains functions and may perform input, output, files and file processing, use arrays and vectors and/or c-string/string arrays, flow of control, and/or calculations. 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 array's 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 azray of integers // A unique.Ptr is a small, fast, move-only smart // pointer usually used for managing resources // with exclusive ownership semantics unique_ptr newcopy (new int [SIZE 11) Your program should display 0 18 27 3 14 95 after the element shift function does its work. The Functions (in separate files): 1) 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. 2) 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, that's fine. Know that you can get by with just using one

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!