Get in touch with us
Send us an e-mail
Question
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 <iostream>
#include <vector>
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<int> _s;
};
#endif
The member functions must be written in a file Set.cpp. Now consider which can contain duplicate items. Thus a Set is a Bag but not vice versa in general. Design a polymorphic class hierarchy for Sets and Bags. The header file for the Set class in this hierarchy must be given in Set.h and the header file for Bag class must be given in Bag.h. Provide the implementation files Set.cpp and Bag.cpp.. The following are some examples of Bag intersection (), and Bag union ().∩∪
{1,2,2,2,3,3}{1,1,2,2,3} = {1,2,2,3} ∩
{1,2,2,2,3,3}{1,1,2,2,3} = {1,1,2,2,2,3,3}∪
You must clearly identify which member functions must be virtual
Summary
The question belongs to Computer Science and it discusses about designing a polymorphic class hierarchy for sets and bags.
Total Word Count NA
I had taken the help from HwA to write the assignment on consumer protection laws in the UK. I needed to include a recent case study in the assignment essay and the commercial law assignment expert at HwA knew the best example to incorporate. I got an A in the assignment and that helped boost my grade for the entire term.
The care and patience with which the online Labor Economics expert at HwA guided me through the assignment topic was simply amazing. She was always ready with the solutions to my queries and incorporated any suggestions that I made into the Labor Economics Assignment essay. It was just the guidance I needed to write my Labor economics assignment.
After completing my graduation in accountancy I decided to pursue a course in taxation. However, my boat started to rock as an when I was faced with the complexity of the assumptions and considerations which needs to be made whilst calculating a business tax. I was clueless and I was looking for means to make things steady. It was then that my senior in the university suggested that I should take help from HwA and I did. The result was magnificent and while reading out their reports and calculations in my own free time, I also learned a lot.
I must confess that I was horribly bad in logic circuit designs. I just messed up the symbols and eventually my grades hampered. But whilst browsing the net I landed on HwA and ever since I started taking their help, I never had to look back. The experience hand been fantastic and I recommend all my friends to come and take help from this website.
I was badly stuck while preparing my patient report assignment help and had no clue on how to incorporate all the minute details into the entire perspective. Luckily then only one of my friends suggested that HwA is the best place to get original work done and he was absolutely right. From the moment I contacted them I became certain that these people know the stuff and then they helped me deliver a brilliant patient report fetching me excellent grades in my class. It also taught me on how to write patient reports.
Comments
this is a very good website
I have 50 questions for the same test your page is showing only 28
hi can you please help or guide me to answer my assignments. thanks
hi can anyone help or guide me to my assignments. thanks
This solution is perfect ...thanks
Hello Allison,I love the 2nd image that you did! I also, had never heard of SumoPaint, is something that I will have to exolpre a bit! I understand completely the 52 (or so) youtube videos that you probably watched. Sometimes they have what you want, sometimes they don't! However, it is always satisfying when you are able to produce something that you have taught yourself. Great job!Debra 0 likes
Perfect bank of solution.
great !
thanks for the quick response. the solution looks good. :)
thnx for the answer. it was perfect. just the way i wanted it.
works fine.