Question: need c++ format; need ELASTICARRAY.h and ELASTICARRAY.cpp and main.cpp; here is start code: --------------------------------------------------------------------------------------------------- #ifndef _ELASTICARRAY_H_ #define _ELASTICARRAY_H_ class ElasticArray{ public: ElasticArray(int size); int size()
need c++ format;
need ELASTICARRAY.h and ELASTICARRAY.cpp and main.cpp;
here is start code:
---------------------------------------------------------------------------------------------------
#ifndef _ELASTICARRAY_H_
#define _ELASTICARRAY_H_
class ElasticArray{
public:
ElasticArray(int size);
int size() const { return _size; }
int& at(int i);
~ElasticArray();
private:
int* _array = nullptr;
int _size = 0;
};
#endif
--------------------------------------------------------------------------------------------------
#include"ElasticArray.h"
#include
#include
using namespace std;
ElasticArray::ElasticArray(int size)
{
if (size > 0)
{
_size = size;
_array = new int[size];
std::cout
}
else
_array = nullptr;
}
ElasticArray::~ElasticArray()
{
delete [] _array;
std::cout
}
int& ElasticArray::at(int i)
{
try{
if(i = _size)
throw std::out_of_range("Array index out of range.");
return _array[i];
}
catch(const char* a){
cout
}
}
------------------------------------------------------------------------------------------------------





ElasticArray Description When you are finished, the ElasticArray class will be able to do these things that the DynamicArray class could not do ElasticArray will be default-constructable ElasticArray will be copy-constructable ElasticArray will be copy-assignable and will exhibit correct "by-value" semantics. ElasticArray will implement: o a push back) method that will allow new items to be added at the end of the array. o front () and back() methods that will allow the items at the front and back (respectively) of the array to be accessed o a pop back) method that will return the value of the item at the back of the array and then remove that item from the array o a shrink_to fit() method that will reduce the internal storage of the object to exactly match the current logical array size. Now we will look at some details about how to make each of these features a reality. Notice that we will not necessarily implement them in the order they are listed. Sometimes it is better to choose an order of implementation that will allow you more freedom to test and debug incrementally as you go along
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
