Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Code in C++! Header, cpp, and main file. Most of the code skeleton is already here. Read instructions: Create class lntegerSetfor which each object can
Code in C++! Header, cpp, and main file. Most of the code skeleton is already here.
Read instructions:
Create class lntegerSetfor which each object can hold integers in the range 0 through 100. A set is represented internally as an array of ones and zeros. Array element a[] is 1 if integer jis in the set. Array element ali] is 0 if integer j is not in the set. The default constructor initializes a set to the so-called "empty-set," i.e., a set whose array representation contains all zeros Class IntegerSethas the following member functions: 1. inputSet read values from user 2. unionQfSets: create a third set that is the set union of two existing sets (i.e., an element of the third array's is set to 1 if that element is 1 in either or both of the existing sets, and an element of the third set's array is set to 0 if that element is 0 in each of the existing sets) 3. create a third set that is the set intersection of two existing sets (i.e., an element of the third array's is set to 1 if that element is1 in both of the existing sets, and an element of the third set's array is set to 0 if that element is 0 in either of the existing sets). 4. printSet: print a set as a list of numbers separated by spaces in between a pair of curly braces. Print only those elements which are present in the set (i.e., their position in the array has a value of 1) The following is a template that you need to use for your program - you need to fill in the necessary components in the template to make it work // Header file for class IntegerSet #ifudef INTEGER-SET-H #define INTEGERSETH - - public: lntegerSetl); // constructor / Write a member funcion prototype for UnionQfSets*/ vaid inputSet0: // read values from user vaid printSet) const; private: int set[ 101]; // range of 0 100
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started