i need help using the following .h file to
Write a definition of a member function
void complementSet(); which for a set A, the complement of A is the
difference of U-A, where U is the universe set.
Would the universe set be the monthsSet istself??
Thank you all very much for all your help
This is the .h file..
#ifndef H_monthsSet
#define H_monthsSet
#include <iostream>
using namespace std;
class monthsSet
{
private:
bool months[12];
public:
monthsSet();
int cardinality();
void print();
bool membership(int month);
void differenceSet(monthsSet &B);
void unionSet(monthsSet &B);
void intersectionSet(monthsSet &B);
bool equals(monthsSet &B);
void copySet(monthsSet &B);
bool emptySet();
void clearSet();
void insertMonth(int month);
void deleteMonth(int month);
};
monthsSet::monthsSet()
{
for (int i=0; i<12; i++)
months[i] = false;
};
int monthsSet::cardinality()
{
int count=0;
for (int i=0; i<12; i++)
{
if (months[i])
count++;
}
return count;
};
void monthsSet::print()
{
for (int i=0; i<12; i++)
{
if (months[i])
switch (i)
{
case 0:
cout << "january "; break;
case 1: cout << "february "; break;
case 2: cout << "march "; break;
case 3: cout << "april "; break;
case 4: cout << "may "; break;
case 5: cout << "june "; break;
case 6: cout << "july "; break;
case 7: cout << "august "; break;
case 8: cout << "september "; break;
case 9: cout << "october "; break;
case 10: cout << "november "; break;
default: cout << "december"; break;
}
}
cout << endl;
};
bool monthsSet::membership(int month)
{
return (months[month]);
};
void monthsSet::differenceSet(monthsSet &B)
{
for (int i=0; i<12; i++)
if (B.months[i])
months[i] = false;
};
void monthsSet::unionSet (monthsSet &B)
{
for (int i=0; i<12; i++)
if (B.months[i])
months[i] = true;
};
void monthsSet::intersectionSet (monthsSet &B)
{
for (int i=0; i<12; i++)
if (months[i] && !B.months[i])
months[i] = false;
};
bool monthsSet::equals (monthsSet &B)
{
for (int i=0; i<12; i++)
if (months[i] != B.months[i])
return false;
return true;
};
void monthsSet::copySet (monthsSet &B)
{
for (int i=0; i<12; i++)
if (B.months[i])
months[i] = true;
else
months[i] = false;
};
bool monthsSet::emptySet ()
{
for (int i=0; i<12; i++)
if (months[i])
return false;
return true;
};
void monthsSet::clearSet ()
{
for (int i=0; i<12; i++)
months[i] = false;
};
void monthsSet::insertMonth(int month)
{
months[month-1] = true;
};
void monthsSet::deleteMonth(int month)
{
months[month-1] = false;
};
#endif
I thank you for any help or advice you may have.