and duplication checks. Your class should consist of the member variables. int * values;// A pointer to an int . This member points to the dynamically allocated array of integers (which you will be allocating in constructor
Note: Write a c++ code and also include the header file and main function also.
1. Define a class Container for storing integer values, regardless of the sequence and
duplication checks. Your class should consist of the member variables.
int * values;// A pointer to an int . This member points to the dynamically
allocated array of integers (which you will be allocating in constructor).
int capacity;// An integer that shows total capacity of your container
int counter;// A counter variable which increments upon every insertion
operation; shows total number of elements inserted yet in container
2. You would need a parameterized constructor with single parameter int c; i.e. it
initializes the capacity variable, showing the total capacity of the container, and also
allocating memory to array. Set the value of counter to 0.
Container(int c)
Also a copy constructor Container(Container &copy)
Implement the functions mentioned below:
3. Function bool isFull( ), to check if the counter has reached to the max capacity of your
array return true (counter = =capacity), else return false.
4. Function void insert(int val) takes single parameter, The function requires you to place
that item in array, but before placing item, do call isFull( )to check if we have not
reached to the capacity. Update the counter variable as well.
5. Function bool search( int val)takes 1 parameter. Provided value has to be searched in
array, note that array is not passed in the parameter list of this function; because it is
already accessible i.e. array is a part of this class. Return true if you found the value.
6. Function void remove(int val)removes the value after searching it in array. But the most
important thing about this function is, that suppose user provided a value which is placed
at 3 rd index of array of size 5, so accomplishing the goal of removing value would require
you to apply the logic of shifting the value from 4 th index to 3 rd and the value from 5 th index
to 4 th . Don’t forget to update counter.
7. Write a function void Print( )to print the values of array.
8. A destructor
Step by step
Solved in 3 steps with 1 images