Answer to Question #189939 in C++ for sayyam butt

Question #189939

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.


1
Expert's answer
2021-05-08T22:32:32-0400
#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:





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS