C++/c++

first thanks for pointing me in the right direction on that last program.

i have written another program in which i am almost done with, but it has a few kinks i am stuck on. thanks for any help you can give.

program background:

create class IntegerSet where each object can hold integers in range of 0 - 100. a set is represented internally as an array of ones and zeros. for example, array element a[i] is 1 if integer i is in the set, and arrary element a[j] is 0 if integer j is not in the set. the default constructor initializes a set to the " empty-set," a set whos array representation contains all zeros. the only thing im having trouble with for some reason is the void emptySet() function definition, IntegerSet deleteElement functions() deleteElement member fuction that deletes m by setting set[m] to 0. the program compiles and you can enter numbers, but im not getting the output desired.

this is a sample of what the Output should look like:
Enter Set A:
Enter an element (-1 to end):45
Enter an element (-1 to end):76
Enter an element (-1 to end):34
Enter an element (-1 to end):6
Enter an element (-1 to end):-1
Entry Complete

Enter Set B:
Enter an element (-1 to end):34
Enter an element (-1 to end):8
Enter an element (-1 to end):93
Enter an element (-1 to end):45
Enter an element (-1 to end):-1
Entry Complete

Union of A and B is:
{ 6 8 34 45 76 93}

Intersection of A and B is:
{ 6 34 45 76 77}

Inserting 77 into set A
Set A is now:
{6 34 45 76 77}

Deleting 77 from set A
Set A is now: {6 34 45 76}
invalid insert attempted!
invalid insert attempted!

For emptySet:
==========================
You can assign 0 to every element of set using a for loop
void IntegerSet::emptySet ()
{
for(i = 0; i < 101; ++i) set[i] = 0;
}
Or, you could use memset instead of the "for" loop to make the memory of set all 0, like this:
void IntegerSet::emptySet ()
{
memset(set, 0, sizeof(set[0]) * 101);
}

The emptySet method is a member of the IntegerSet, so you specify the definition it by prefixing it with "IntegerSet::" You were missing the prefix.

For deleteElement
=======================================
I suggest that you make deleteElement symmetric with insertElement. Notice that insertElement takes an element and inserts it into the IntegerSet being worked on. The insertElement does not return a new set.
The deleteElement should work in the same way. It should modify the IntegerSet being worked on and not return a new set. So deleteElement should be declared as
void deleteElement ( int );
and defined as
void IntegerSet::deleteElement ( int m)
{
if (isValidEntry(m)) set[m] = 0;
else cerr << "Invalid delete attempted!"
}

Default constructor
===============================
Your assignment requires a default constructor which is missing. Remember to put in a default constructor to assign 0 to every element of the set. You can call the emptySet from the constructor to do the actual work.

isEqualTo
=================================
Look closely at your isEqualTo method.
bool IntegerSet::isEqualTo( const IntegerSet &r )
{
for ( int v = 0; v < 101; v++ )
if ( set[ v ] == r.set[ v ] )
return true; // sets are not-equal
else
return false; // sets are equal
} // end function isEqualTo
Is it examining all elements in the set? It is examining only the first element, and making a return based on it. You can say that two sets are UNequal as soon as you find one element which does not match, but you cannot say two sets are equal until you examine all elements. You cannot return true until all elements are examined. I will leave it to you to rewrite it.

Final comment
=================================
Notice that it is not a good practice to hard-code magic numbers like 101 throughout your program. If you ever need to change to say 200 elements, you would need to make many changes in your code. If you miss a spot, your program will not work properly. As an exercise, try defining a constant integer for your set size, and go through your program and change all the magic numbers to be in terms of the SetSize. For example, inside your IntegerSet class you can do this:
private:
static const int SetSize = 101;
int set[ SetSize ]; // range of 0 - 100