```c++
#include<iostream>
using namespace std;
class set{
public:
set(){
pelem=NULL;
count=0;
}
set(const set& s1){
count=s1.count;
pelem=new int[count];
for(int i=0;i<count;i++)
*(pelem+i)=*(s1.pelem);
}
void print();
set(int *a,int num){
count=num;
pelem=new int[count];
for(int i=0;i<count;i++)
pelem[i]=a[i];
}
set operator +(const set& s1);
set operator -(const set& s1);
set operator *(const set& s1);
void operator =(const set& s1);
bool exist(int x);
~set(){
count=0;
delete []pelem;
}
private:
int* pelem;
int count;
};
void set::print(){
for(int i=0;i<count;i++){
cout<<pelem[i];
if(i<count-1)
cout<<" ";
}
cout<<endl;
}
bool set::exist(int x){
for(int i=0;i<count;i++){
if(pelem[i]==x)
return true;
}
return false;
}
void set::operator =(const set& s2){
count=s2.count;
pelem=new int[count];
for(int i=0;i<count;i++)
pelem[i]=s2.pelem[i];
}
set set::operator +(const set& s1){
set s;
s.count=s1.count;
s.pelem=new int [count+s1.count];
for(int i=0;i<s.count;i++)
s.pelem[i]=s1.pelem[i];
for(int i=0;i<count;i++){
if(!s.exist(pelem[i])){
s.pelem[count]=pelem[i];
s.count++;
}
}
return s;
}
set set::operator -(const set& s1){
set s;
s.count=count;
s.pelem=new int [count];
for(int i=0;i<count;i++)
s.pelem[i]=pelem[i];
for(int i=0;i<s1.count;i++){
if(s.exist(s1.pelem[i])){
for(int k=i;k<count;k++){
s.pelem[k+1]=s.pelem[k];
}
s.count--;
}
}
return s;
}
set set::operator *(const set& s1){
set s;
s.pelem=new int [count];
s.count=0;
for(int i=0;i<count;i++){
if(exist(s1.pelem[i])){
s.pelem[i]=s1.pelem[i];
s.count++;
}
}
return s;
}
int main(){
int b[5]={1,3,5,7,9};
int c[3]={1,4,6};
set A(b,5);
set B(c,3);
cout<<"集合A:";
A.print();
cout<<"集合B:";
B.print();
set C=A+B;
cout<<"A+B=";
C.print();
C=A-B;
C.print();
C=A*B;
C.print();
return 0;
}
```
自己不会设断点或单步调试吗?
operator= 应该返回set&