Implement a template class that encapsulates a dynamicarray named sequence and test it using a suitable driver program (break the program into 3 files- definition,implementation and driver).
class sequence : public SeqInterface< ItemType>
Your class should include the following data members:
A pointer to the array
A variable to hold the current array
A variable to keep track of the number of elements currently being used (num_used).
Include the following methods in the class:
A default constructor that dynamically allocates an array of size 10 and initializes capacity to 10 and num_used to 0.
A one argument constructor that dynamically allocates an array of the size passed as an argument and initializes capacity to that number and num_used to 0.
A function to determine if the array is full. (return a bool value)
A function to determine if the array is empty. (return a bool value)
A function that returns the array maxCapacity.
A function that returns the number of elementscurrently being used.
A function named front that returns a reference to the first entry in the container.
A function named back that returns a reference to the last entry in the container.
A void function named push_back that appends the value passed as an argument to the back of the container. (increases num_used by 1)
A void function named pop_back that removes the back entry from the container and returns it through a reference parameter. (decreases num_used by 1)
A function named at that returns a reference to an entry at the position passed as an argument. (performs a bounds check)
A void function named resize that changes the containers capacity to the size passed as an argument.
A void function with 2 parameters named insert to add an item to the container at the given position.(increases num_used by 1)
A destructor that will release the allocated memory.
Make the destructor virtual:
virtual ~sequence( );
Note: Make sure you check for out of bounds conditions and the cases when the array is full.
Your driver program should declare a sequence object and implement a menu system to test the class. Add values input from the keyboard to the sequence and then manipulate the entries by making calls to the public functions in the class. Print the contents of the sequenceafter the initial input and after all the manipulations are performed.
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.