Write a template class called ValSet which represents a math

Write a template class called ValSet, which represents a mathematical set of values. For convenience I will refer to the generic type of these values as \"T\". The ValSet will store the values in an array, which will need to grow if it gets full. ValSet should have the following data members:

a pointer-to-T that points to a dynamically allocated array (of T) that holds the values that are part of the set

an int that holds the current size of the array - it will need to be updated whenever the add() method creates a larger array

an int that holds the number of values that are currently part of the set - it will need to be updated in the add() and remove() methods

The ValSet class should have the following methods:

a default constructor that initializes the pointer data member to point to an array of size 10, initializes the variable that stores the size of the array to 10, and initializes the variable that stores the number of values in the set to zero

a copy constructor that initializes the pointer data member to point to an array of the same size as the one being copied, copies over the array values, and also copies the values for the size of the array and the number of values in the set

an overloaded assignment operator that initializes the pointer data member to point to an array of the same size as the one being copied, copies over the array values, copies the values for the size of the array and the number of values in the set, and returns the object pointed to by the this pointer

a destructor that deallocates the dynamically allocated array

Solution

I have implemented or overloaded the [] operator so that you can get the value of array by position. If you have any doubt you can ask me regarding that.

Write a template class called ValSet, which represents a mathematical set of values. For convenience I will refer to the generic type of these values as \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site