Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 8 Due Date: See Blackboard Source File: Input: Output: Value: -/2336/08/1ab08. (CCPPIcppl c++]cclcxxl cp) Under control of main function Under control of main function

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Lab 8 Due Date: See Blackboard Source File: Input: Output: Value: -/2336/08/1ab08. (CCPPIcppl c++]cclcxxl cp) Under control of main function Under control of main function The purpose of this assignment is to become more familiar with the process of providing overloaded operators for a class. The IntegerSet class from Labs 04 and 06 will be modified to provide: an overloaded output operator for displaying an IntegerSet overloaded operators for adding an element to an IntegerSet and deleting an element from an Inte- gerSet an overloaded operator to compute the complement of an IntegerSet, and an overloaded assignment operator for assigning one IntegerSet to another (this is necessary since the data includes an array) private A header file is shown in Figure 1, a sample main function for testing your implementation is shown in Figure 2, and a sample execution sequence is shown in Figure 3. To use the Makefile as distributed in class, add a target of lab08 to targets2srcfileswithlibrary 1 #ifndef LAB08-H 2 #define LAB08-H #include #include 4 7 using namespace std; const uint N40 class IntegerSet usII overloaded output operator for printing IntegerSet set to // output stream out friend ostream& operator 4 using namespace std; s int main) uint e, j, n; IntegerSet s, t; while (cin >> n) cin >> e cout cd 2336 2 newuserdcsunix /2336> /getlab.kah 08 * Checking to see if a folder exist8 for Lab 08, . .No *Creating a folder for Lab 08 Checking to see if Lab 08 has sample input and output files..Yes 6*Copying input and output files for Lab 08 from folder /usr/local/2336/data/08 to folder ./08 Checking to see if /usr/local/2336/arc/lab08main.c exiats. . .Yes 9Copying file /uar/local/2336/src/lab08main.C to folder./08 10*Checking to see if /usr/local/2336/include/1ab08.h exists. . .Yes 11*Copying file /uar/local/2336/include/lab08.h to folder ./08 12Copying file /usr/local/2336/arc/Makefile to folder -/08 13*Adding a target of lab08 to targets2arcfileswithlibrary 14Touching file ./08/lab08.cpp * Edit file ./08/1ab08.cpp in Notepad++ 6 newuseracsunix "/2336> cd 08 17 newuseracsunix "/2336/08> 1s is 01.dat 01.out Makefile lab08.cpp lab08.h newuseracsunix "/2336/08> make lab08 2gt -g -Wall -std-c++11lab08main.C -I/uar/local/2336/include -I 21 g+ -g-Wall -std-c++11-c lab08.cpp -I/usr/local/2336/include -1 22g -o lab08 lab08main.o lab08.o -L/usr/l 23 l,-whole-archive -1lab08-wl,-no-vhole-archive -1m -1bits 24 newuserdcsunix "/2336/08> cat 01.dat 26 1 2 4 8 16 32 27 10 2 3 6 9 12 15 3 6 9 12 15 30 4 8 12 16 20 24 28 32 36 40 44 48 52 31 48 32 0 1 2 3 45 6 7 8 9 s 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 as 30 31 32 33 34 35 36 37 38 39 36 40 41 42 43 44 45 46 47 Figure 3. Commands to Compile, Link, &Run Lab 08 (Part 1 of 2) ss neusercsunix /2336/08> cat 01.dat I ./lab08 9 -11,2,4,8,16,32 40 B 4 s.cardinalityO-6 {0.3,5,6,7,9,10,11,12,13,14,15 , 17, 18, 19.20,21,22,23,24,25 , 26, 27, 28, 29, 30, 31, 33,34,35,36,37,38,39) 42 t = s t.cardinality-34 4s s.cardinalityO-0 47 -13,6,9,12,15 4 B 4s.cardinalityO-s {0.1,2,4,57,8,10,11,13, 14, 16, 17, 18, 19, 20, 21, 22, 23,24,25,26,27,28,29,30,31,32,33,34,35,36,37 ,38,39 so t = S t.cardinalityO-35 s.cardinalityO-0 -14,8,12,16,20,24,28,32,36) s.cardinalityO-9 6 B {0,1,2,3,5,6,7,9,10,11,13 , 14, 15,17,18, 19, 21, 22, 23, 25,26,27,29,30,31,33,34,35 , 37,38,39) ss t = t.cardinalityO-31 61 S 61 s.cardinalityO- 63 s= {0.1.2.3.4 ,5 ,6 , 7, 8, 9, 10, 11 " 12, 13, 14, 15,16 , 17, 18, 19, 20, 21, 22,23,24,25,26 , 27, 28,29,30,31,32 , 33 , 34,35,36,37,38,39) G s.cardinality)-40 7t.cardinalityO-0 co s.cardinalityO-0 T2 B 8,cardinality() O - 74 t {0.1,2,3,4,5,6,7,8,9,10,11,12,13 , 14, 15,16 , 17, 18, 19, 20, 21, 22,23,24,25,26,27,28,29,30,31 ,32,33,34,35,36,37,38,39) = 7s t.cardinality-40 7s.cardinalityO-0 9 neuser caunix /2336/08> cat 01.dat I ./lab08 > my.out so neuser caunix /2336/08> diff 01.out my.out s newusercsunix /2336/08> Figure 3. Commands to Compile, Link, & Run Lab 08 (Part 2 of 2) #include // overloaded output operator for printing IntegerSet set to // output stream out ostream& operatorisValid(e) && !this->isMember(e)) myset . bitvector(this-word(e)]=setBit (this->bitvector[this-word(e)],this->bit(e), 1); return mySet; IntegerSet IntegerSet::operator-(uint e) const // if e is valid and a member of the set, delete e from set IntegerSet mySet(*this); return mySet; IntegerSet IntegerSet::operator-) const // complement of a Set IntegerSet myComplement; //myComplementmyComplement -5; return myComplement; IntegerSet& IntegerSet::operator-(const IntegerSet& rhs) // *this-rhs if (this-&rhs) for (uint e=0;ebitVector[this->word (e)]-setBit(this->bitVector[this->word(e)],this->bit(e), 1); else //*this *this - e; this->bitVector[this->word (e)]-setBit(this->bitVector[this->word(e)],this->bit(e), 1); return *this<>

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

More Books

Students also viewed these Databases questions