平常作业共 2 次平常作业(1)定义、实现并测试表达由整型数元素组成的集合类型 IntSet
需提供的操作至少应涉及:构造函数析构函数拷贝构造函数插入元素删除元素清空集合集合并集合交集合差集合显示输出集合显示输出的格式为{元素 1, 元素 2,…},空集的输出为{}
/* intset
h */#ifndef INTSET_H#define INTSET_Hclass IntSet {int cursize,maxsize; int *x; bool member(int t) const;public:IntSet(int m = 100);//构造函数IntSet(const IntSet&);//拷贝构造函数~IntSet();// 析构函数void insert(int t);// 插入元素void remove(int t);// 删除元素void clear();//清空集合void print();//集合显示输出IntSet setunion(const IntSet&);//集合并IntSet setdifference(const IntSet&);//集合差IntSet setintsection(const IntSet&);//集合交};#endif/* intset
cpp */#include "stdafx
h"#include #include using namespace std;#include "intset
h"IntSet::IntSet(int m) { if (m