I am working on a project for school. I read the book but I'm still having trouble getting my program to function. We are working with multisets and are using 3 files. We have a multiset.h header file that is only supposed to contain the class definition. This was given to us to use and we aren't supposed to change anything in the public part of the file. We then have a multiset.cpp file that should contain out implementation of the member functions in the multiset class. Our final file is a project2.cpp file that is supposed to contain the main program and code to test each operation in the multiset class. I'm working on the first two class definitions at the moment. This is the code I have so far...
This is the multiset.h file.
#include<vector>
#include<iostream>
#ifndef MULTISET_H
#define MULTISET_H
using namespace std;
class multiset
{
public:
multiset( ); // constructs an empty multiset
multiset( int ); // constructs a multiset with one item
multiset _union( const multiset& ) const; // union operation (notice underscore _)
multiset intersect( const multiset& ) const; // intersects two multisets
multiset difference( const multiset& ) const; // difference of two multisets
multiset join( const multiset& ) const; // joins two multisets
multiset unique( ) const; // returns unique items
int length( ) const; // total number of items
int occurrence( int ) const; // occurrence operation
void display( ) const; // display the contents of the multiset
// as { item, item, item ... }
void print( ) const; // print the contents of the multiset
// as { (item,count), (item,count) ... }
// overloaded operators performing the intersection, difference, union and join operations
multiset operator* ( const multiset& ) const; // intersection operation (A * B)
multiset operator- ( const multiset& ) const; // difference operation (A - B)
multiset operator|| ( const multiset& ) const; // union operation (A || B)
friend multiset operator+ ( const multiset&, const multiset& ); // join operation (A + B)
private:
vector<int> multiSet;
vector<int>multiSet1;
};
#endif
This is the multiset.cpp file
#include "multiset.h"
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
multiset::multiset( ){
this->multiSet = multiSet;
}//end multiset
multiset::multiset(int){
multiSet[0] = 1;
this->multiSet = multiSet;
cout<<multiSet[0];
}//end multiset
And this is my project2.cpp file
#include <iomanip>
#include <iostream>
#include <cmath>
#include "multiset.h"
void main(){
multiset::multiSet{
cout<<multiSet[0];
}
}//end main
Now I know that the last file is wrong but I believe that the other two are correct. My question is how can I get test cases to work in the main area? For the first case I just want to be able to show that the multiset is empty but I'm not sure how to go about it. The same with the second case where I want to show that it has a multiset with 1 item. Any help would be appreciated.