Implement a templated Ordered Array class, which stores all items in line with their natural ordering. Your class must contain the following methods.
Constructor for an OrderedArray. The grow_size lets the user to stipulate by how much they want the ordered array to grow when the array needs to be resized.
Default constructor. The grow_size should default to any sensible value.
Destructor. The OrderedArray must free all memory, including that which is dynamically allocated by it when it is destructed.
void push(const T&newElement)
Puts an element into the array in order. Your array should insert a copy of the element on pushing.
Returns the number of elements in the array that can be accessed publicly i.e., it should return the number of elements added to the array and not its capacity.
T getElement(int index)
Returns a copy of the element corresponding to the given index. A default instance should be returned for an out-of-range value.
bool remove(int index)
Takes one argument corresponding to the index of the element you want to remove and removes that element from the array. Out-of-range values should be dealt with by returning false. Successful removal should return true.
int search(const T&target)
Searches for a specific target value in the array. The search should return the index in the array containing the element. There are a number of standard search options here e.g., you may choose either a linear search or a binary search. If the element is not found, a negative integer should be returned.
Empties the array and frees any memory used by the array in storing the objects.