Question: Add member functions setUnion ( ) , setIntersection ( ) , and setDifference ( ) . The functions should all return the resulting LinkedSet object.
Add member functions setUnion setIntersection and setDifference
The functions should all return the resulting LinkedSet object. We won't need to throw a CapacityExceeded exception in the setUnion function, because the Set will have unlimited capacity. You'll still need the DuplicateItemError exception in your insert function.
You may use contains and the Node class accessors and mutators, but, other than those, do not use any explicit function calls in your definitions of these three functions! The operations must be coded without explicitly calling any other functions to help. The practice manipulating the pointers directly will be extremely valuable.
#ifndef LINKEDSETH
#define LINKEDSETH
#include "SetInterface.h
#include "Node.h
namespace csset
template
class LinkedSet : public SetInterface
public:
LinkedSet;
LinkedSetconst LinkedSet& aSet;
virtual ~LinkedSet;
int size const override;
bool empty const override;
void insertconst ItemType& newEntry override;
void eraseconst ItemType& anEntry override;
void clear override;
bool containsconst ItemType& anEntry const override;
int countconst ItemType& anEntry const override;
std::vector toVector const;
LinkedSet setUnionconst LinkedSet& set const;
LinkedSet setIntersectionconst LinkedSet& set const;
LinkedSet setDifferenceconst LinkedSet& set const;
private:
int itemCount;
Node headPtr;
Node getPointerToconst ItemType& target const;
;
#endif
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
