Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Create a templated class called Set that will use ArrayBag as a data member to be a as a implementation (use inheritance>. The Set

C++

Create a templated class called Set that will use ArrayBag as a data member to be a as a implementation (use inheritance>. 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:

  1. add elements to set1
  2. add elements to set2
  3. remove an element from set1
  4. remove an element from set2
  5. do a union of set1 and set2 into set3
  6. do an intersection of set1 and set2 into set3
  7. print set1, set2, and set3
  8. 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;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

13. Identify the refusal of the return in Dances with Wolves.

Answered: 1 week ago