Question: Create a templated class called Set that will use ArrayBag as a data member to be a has a implementation. The Set will have the

Create a templated class called Set that will use ArrayBag as a data member to be a has a implementation. The Set will have the following public functions:

bool add(const ItemType& newEntry)

The above Set functions will invoke the data member ArrayBag. Note: there are no duplicates in the sets so the Set add should not allow duplicates (do NOT change the ArrayBag code). Also add to Set the following overloaded operator:

Set operator+(const Set&) // do a union

Set operator-(const Set&) // do an intersection

friend ostream& operator<<(ostream&, const Set&) // print the set

Put the class definition in Set.h, implementation in Set.cpp, and a main 3 files all together. Have main create 3 Set objects that are unsigned integers then create a menu like so:

add elements to set1

add elements to set2

remove an element from set1

remove an element from set2

do a union of set1 and set2 into set3

do an intersection of set1 and set2 into set3

print set1, set2, and set3

quit

Have the add elements loop and add positive integers until you enter a 0. You can create extra functions (separate from the Set class) to make it easier.

Printing would look like:

Which set to print? 1

Set 1 has 3 elements of:

11

5

33

With the overloaded operators, you should be able to do something like:

set3 = set1 + set2;

Submit all files.

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!