Implement the following set class a set is a collection of


Problem:

Implement the following Set class. A set is a collection of items with no duplicates. The following class implements a set of integers.

#ifndef SET_H 
#define SET_H 
#include  
#include  
using namespace std; 
class Set 

// friend operator functions 
friend ostream &operator<<(ostream & out, const Set & s); 
friend istream &operator>>(istream & in, Set & s); 
public: 
// Constructors 
Set(); // default constructor 
Set(const Set & s); // copy constructor 
// destructor 
~Set(); 
// operator functions 
Set operator||(Set & s); // union of the set with the set s 
Set operator&&(Set & s); // intersection of the set with the set s 
const Set& operator=(const Set & s); // assignment 
bool operator==(const Set & s); // equality 
int& operator[](int index); // returns modifiable lvalue 
int operator[](int index) const; // returns rvalue 
// Set membership functions 
bool member(int m); // The integer m is a member 
void add(int m); // add the integer m to the set 
void remove(int m); // remove the integer m from the set 
private: 
vector _s; 
}; 
#endif

The member functions must be written in a file Set.cpp. Provide a corresponding class template for the class Set. All of your code must be given in the file SetTemplate.h. Provide a driver program for your class template.

Additional Information:

This question is from Computer Science and it explains about providing the class template for the class set given.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Implement the following set class a set is a collection of
Reference No:- TGS01109864

Now Priced at $20 (50% Discount)

Recommended (92%)

Rated (4.4/5)