I have a MyPoly class where I implemented my own equal operator ( = ). When I try this code everything works fine and my implemented = is being called.
MyPoly mp = MyPoly(arr , 4);
MyPoly copy;
copy = mp;
But when I write this:
MyPoly mp = MyPoly(arr , 4);
MyPoly copy = mp;
It doesn't use my implemented = , and then when the destructor is called I get a run time error.
Can someone explain why these codes are different?