Implement MeraSet2 class similar to last assignment, Add following members:
operator =; // assignment operator, makes deep copy
Copy constructor
operator []; // implement subscript operator, to display individual element of a set.
#include<iostream>
using namespace std;
class MeraSet2{
public:
MeraSet2(){}
MeraSet2(const MeraSet2 &MS){
cout<<"Copy construcotr"<<endl;
}
MeraSet2& operator = (const MeraSet2 &MS){
cout<<"Assignment operator"<<endl;
return *this;
}
MeraSet2& operator[] (const MeraSet2 &MS){
cout<<"Assignment operator"<<endl;
return *this;
}
};
int main(){
MeraSet2 MS1,MS2;
MS2=MS1;
MeraSet2 MS3=MS1, MS4;
MS4=MS1;
MS4=MS2;
MS4=MS3;
getchar();
return 0;
}
Output:
Comments
Leave a comment