Question: Create a class named Set (like Sets in Mathematics) having following private members: int *array_set; int size The class should have the following member functions:

Create a class named Set (like Sets in Mathematics) having following private members:

int *array_set;

int size

The class should have the following member functions:

Set () initializes empty object

Set (int s) initializes a dynamic array of size s with all elements equal to zero. This array represents our set.

Set (int *ref, int s) initializes the array to the ref array passed as argument having size s.

Set (const Set& obj) copy constructor

Overloaded + operator for union of two sets

Overloaded - operator for intersection of two sets

Overloaded == operator to see if two sets are equal (note that in sets, order of elements does not matter, so {1,2,3} and {3,2,1} are equal sets).

Overloaded >> operator to input all elements of a set

Overloaded << operator to print the entire set

~set ()

Write a testSet() function that creates multiple pointers of Set class that point to Set objects and tests all the functionalities above. Console must have a neat format. Call testSet() function in main().

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!