C++实现集合的交并运算
#include<iostream>
using namespace std;
class SetClass {
int size, maxsize;
int *x;
bool member(int t) const;
public:
SetClass(int m = 50);//构造函数
SetClass(const SetClass&);//拷贝构造函数
~SetClass();//析构函数
void insert(int t);//插入元素
void remove(int t);//删除元素
void clear();//清空集合
void print();//集合显示输出
SetClass setunion(const SetClass&);//集合并
SetClass setintsection(const SetClass&);//集合交
};
SetClass::SetClass(int m)
{
if (m < 1) exit(1);
size = 0;
x = new int[maxsize = m];
}
SetClass::~SetClass()
{
delete x;
}
S