Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class that represents a set. The set class can hold any real number (which includes integers). The set class should have a vector

image text in transcribedimage text in transcribed

Create a class that represents a set. The set class can hold any real number (which includes integers). The set class should have a vector, so that the array can grow when you need more room. Information on vectors can be found on the C++ vector reference page. You will most likely use its "push_back," "erase," "inser" and [] functionality. In addition, your class will have the following constructor Set(): creates an empty set . Member methods void Set:addElement(double element): inserts the new element into the set, only if it does not already exist in the set. If the value already exists, then the element is not added to the set. . Set Set:union(const Set& B): combines the contents of set B with the set object currently calling the method and returns the new set that results from this combination Example: Set A contains1, 2, 3) and Set B contains{2, 3, 5) then the code o .union(B); // returns the set containing {1, 2, 3, 5). Notice it does not have multiple Set Set::intersection(const Set& B): returns the new set containing the intersection of the bool Set: isEqual(const Set& B) : returns true if the set calling the method is equivalent to . Set Set::complement(const Set& universe): returns the complement of the set calling the copies of values 2 and 3. two sets set B and false otherwise method, given the universe passed in, i.e. all values in the universe that are not part of the set o Example: Set A contains (1, 2, 3) and set universe contains (1, 2, 3, 4, 5) A.complement(universe); // returns set (4, 5) . void display() : displays the set in the following format " val1, val2, val3, ..., valn)" where the actual values from the set replace val1, val2, etc Driver file you should create #include "MySet.hpp" // or "MySet.h" #include using namespace std; int main) Set a, b, c, U; for(doublei 1; 10.5; i 0.5) a.addElement(i ); U.addElement(i) for (double k 1 k 11 k+1) b.addElement(k); U.addElement(k); ca.union(b); cout

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_2

Step: 3

blur-text-image_step3

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

ISBN: 1583473858, 978-1583473856

More Books

Students also viewed these Databases questions