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 LINKED_SET_H
#define LINKED_SET_H
#include "SetInterface.h"
#include "Node.h"
namespace cs_set {
template
class LinkedSet : public SetInterface
{
public:
LinkedSet();
LinkedSet(const LinkedSet& aSet);
virtual ~LinkedSet();
int size() const override;
bool empty() const override;
void insert(const ItemType& newEntry) override;
void erase(const ItemType& anEntry) override;
void clear() override;
bool contains(const ItemType& anEntry) const override;
int count(const ItemType& anEntry) const override;
std::vector toVector() const;
LinkedSet setUnion(const LinkedSet& set2) const;
LinkedSet setIntersection(const LinkedSet& set2) const;
LinkedSet setDifference(const LinkedSet& set2) const;
private:
int itemCount;
Node* headPtr;
Node* getPointerTo(const ItemType& target) const;
};
}
#endif
)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!