djJonno 0 Newbie Poster

Hi,
First time posting here.
Basically here's my project description.
Implement classes for “Sets” e.g. (1,3,6) and “Multisets” e.g.(1,3,6,3,6,6). in C++.
Needs to use Dynamic Memory.
A single function CalculateAll(mySet1,mySet2) or CalculateAll(myMulSet1,myMulSet2) which
displays union, intersection etc...
Basically I must use The same function call CalculateAll to work on both classes, set and multiset.

What I have decided so far is to use Multiset as my base class, which has all the methods necessary, such as union, intersection etc.... I then derived my Multiset Class from this and now I am trying to redefine the method for how the items are stored in my derived class Set. (Basically, it does not allow duplicates to be entered).

What I wanted to do was use a Virtual Function and do the following,
mySet1.CalculateAll (mySet2) which will then use the appropriate CalculateAll method (based on whether or not a Set or MultiSet is passed in) and in turn call all the other methods(union, intersection etc..) and display the results.

However in the question I was asked to do it in the form CalculateAll(MySet1,MySet2).

Any ideas on how I can go from doing it the way I wanted to do it to doing it the way I was supposed to do it?!!

Sorry if the explanation of my question isn't the best, my head's muddled at this stage from thinking about it!!
Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.