Question: Please write this program according to the prompt below and using the code provided. Thank you Bag1.cpp Bag1.h The goal of assignment 3 is to
The goal of assignment 3 is to reinforce implementation ofcontainer class concepts in C++. Specifically, the assignment is to do problem 3.5 on page 149 of the text. You need to implement the set operations union, intersection, and relative complement. Your code must implement the style guidelines of the author (preconditions, postconditions, a unit test style - test each implemented fnction and clearly label your output. class invariant, and function efficiencies). Your test program should us You will be provided with bag I.h and bagl.cpp files as reference. You will need to adapt this class to implement a set Here are some typical features of a set: 1. A set can have unique elements only -no duplicates allowed 2. dmion of sets s1 U 2-a new set wilh fl nd s2 withou ny duplicates If sl 1,2,33, s213,4,5) then slus2= {1,2,3,4,5} 3. Intersection of 2 sets sins2 a new set with elements common to both sl and s2 4. Relative complement of sl to s2 a new set with all elements from sl that are not present in s21.2) Here are the changes you should ideally be making to the h and implementation files: 2. You will need to add new functions Union, Intersection and Relative complement, these will need to be non- member friend functions. 3. You should also add a function called contains that checks to see if an entry is already present in the set. It should return a boolean value. This function should be a private function that can be called anytime, you need to insert an entry into a set (to make sure you don't add duplicate entries). 4. You do not need the following functions from the bag class: a. Erase b. Count c. +overloaded function d. overloaded function 5. Do not add any more functions besides the ones listed under 2. &3. 6. Test the 3 set operations and clearly label your imput and outputs. FILE: bagl.cx:x / CLASS IMPLEMENTED: bag (see bag1.h for documentation) / INVARIANT for the bag class: 1. The number of items in the bag is in the member variable used / 2. For an empty bag, we do not care what is stored in any of data: for a non-empty bag the items in the bag are stored in data [0] through data used-1], and we don't care what 's in the rest of data. #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
