Hey everyone,
I'm trying to work with Sets. I have a function Union that takes a class type Set as it's parameter. The function returns the union of class A and B.
Here is my code:
Set Set::Union(Set setB)
{
Set result (maxItems);
for (int i = 0 ; i < maxItems ; i++)
result.items[i] = (items[i] || setB.items[i]) ;
return result ;
}
************************
//copy c-tor if you need it
Set::Set(const Set & sB) // copy c-tor
{
maxItems = sB.maxItems;
items = new bool[maxItems];
for ( int k = 0; k < maxItems; ++k )
items[k] = sB.items[k];
}
Example Use: Set testClass = classA.Union(classB) ;
I'm getting run-time errors, and I'm fairly positive it has something to do with the use of dynamic memory in this function. I need to return the address of the new class result. Thanks for any help. If you need more of my code, just let me know.