Hello, I have been working on a project that manipulates sets (unique elements within an array), and I am having issues with how to go about calling the two sets in the functions of union and intersection. These program fragments are from my main and class implementation files and do compile, but once the program terminates I get a pause then a "RUN FAILED". Any suggestions or tips on what I need to change?
For this code I feel that I am assigning setThree inappropriately.
//Main
cout << "The union of the first and second set: " << endl;
setThree = setThree.setUnion(setOne, setTwo);
setThree.print();
cout << "The common items within these two sets are: " << endl;
setThree = setThree.setIntersection(setOne, setTwo);
setThree.print();
//Class implemenetation
unorderedSetType unorderedSetType::setUnion(unorderedSetType first, unorderedSetType second)
{
for (int i=0; second.length > i; i++)
{
if (first.seqSearch(second.list[i]) == -1)
first.insertEnd(second.list[i]);
}
return first;
}
unorderedSetType unorderedSetType::setIntersection(unorderedSetType first, unorderedSetType second)
{
unorderedSetType third(100);
for (int i=0; first.length > i; i++)
{
if (second.seqSearch(first.list[i]) != -1)
third.insertEnd(first.list[i]);
}
return third;
}
Another separate issue: I am new to "this" pointer and have been experimenting with it. My setUnion function has "this" manipulate setOne when I want it to "temporarily manipulate for this function only." (I'm sure there's a term for that)