Question: you will be implementing a class which acts as a dynamically-sized integer array. When the object is instantiated, it will allocate a dynamic array
you will be implementing a class which acts as a dynamically-sized integer array. When the object is instantiated, it will allocate a dynamic array of integers with the given capacity. 1. Declare and define the default constructor. The default capacity should be set to 1. Therefore, you should allocate a dynamic array of size 1. 2. Declare and define the parameterized constructor. Accept the default capacity as an int and allocate a dynamic array with this size. 3. Create a function named pushValue, which returns an unsigned int and accepts one int. This function should: 1. Add the passed-in int into the next available spot in the array. Assume that a spot will always be available (capacity will always be greater than the number of times push is called). 2. Return the index where the integer was added, starting with O, like a standard C++ array. 4. Create a function named getArray, which returns an int* pointing to the first element of your array, 5. Implement the copy assignment operator. Remember to perform a deep copy. 6. Implement the destructor, which deallocates all memory used by your class.
Step by Step Solution
There are 3 Steps involved in it
include using namespace std class DynamicIntArray private data members int array int capacity int si... View full answer
Get step-by-step solutions from verified subject matter experts
