ler alternative:
operator= returns a copy (not a reference as is conventional), which created using the default copy constructor. In this example it is not used and so a temporary is created. The temporaries x and y are pointing to the same memory as the copy, since the copy constructor is not defined. When the temporary is destroyed its x and y are deleted - then later o2 is destroyed resulting in the same memory getting deallocated twice. 
It's worth noting that there's still a lot that can go wrong with this class, and it needs some further love and attention. Also worth seeing how we can find this error.
Here's what I get when pushing it through the pc-lint online linter.
Note that this includes the problem causing the crash, and a lot of other things that need fixing.
 1  #include <iostream>
 2  
 3  using namespace std;
 4  
 5  class MyClass
 6  {
 7  private:
 8      int *x;
 9      int *y;
10  public: 
11      MyClass()
12      {
13          x = new int[1]; *x = 0;
14          y = new int[1]; *y = 0;
15      }
16      ~MyClass()
17      {
18          if(x!= NULL)
19          {
20              delete x;
21              x = NULL;
22          }
23          if(y!= NULL)
24          { 
25              delete y;
26              y = NULL;
27          }
28      }
29      MyClass operator=(MyClass & rhs)
        _
30      {

diy.cpp  30  Info 1722:  assignment operator for class 'MyClass' does not return a reference to class
diy.cpp  30  Info 1720:  assignment operator for class 'MyClass' has non-const parameter
31          MyClass temp;
32          temp.Set(rhs.x[0], rhs.y[0]);
33          return temp;
34      }
35      void Set(int a, int b)
36      {
37          if(x!= NULL)
38          {           
39              *x = a;
40          }
41          if(y!= NULL)

ler alternative: 
 operator= returns a copy (not a reference point as is ceremonious), which created using the nonpayment transcript constructor. In this example it is not used and thus a temporary is created. The temp x and y are target to the same memory as the transcript, since the copy constructor is not defined. When the temporary is demolish its x and y are deleted - then later o2 is destroyed resulting in the same memory getting deallocated doubly. 
 It's worth noting that there's still a set that can go wrong with this course, and it needs some further sexual love and attention. besides worth seeing how we can find this error. 
 Here's what I catch when pushing it through the pc - lint online linter. 
 Note that this includes the trouble cause the crash, and a lot of other things that need fixing. 
  1   # include < iostream > 
  2  
  3   using namespace std; 
  4  
  5   class MyClass 
  6   { 
  7   individual: 
  8       int * x; 
  9       int * y; 
 10   public: 
 11       MyClass () 
 12       { 
 13           x = modern int[1 ]; * x = 0; 
 14           y = newfangled int[1 ]; * y = 0; 
 15       } 
 16       ~MyClass () 
 17       { 
 18           if(x!= NULL) 
 19           { 
 20               delete x; 
 21               x = NULL; 
 22           } 
 23           if(y!= NULL) 
 24           { 
 25               delete y; 
 26               y = NULL; 
 27           } 
 28       } 
 29       MyClass operator=(MyClass & rhs) 
         _ 
 30       { 

 diy.cpp   30   Info 1722:   assignment operator for course' MyClass' does not return a mention to class 
 diy.cpp   30   Info 1720:   assignment hustler for class' MyClass' has non - const parameter 
 31           MyClass temp; 
 32           temp. Set(rhs.x[0 ], rhs.y[0 ]); 
 33           return temp; 
 34       } 
 35       void Set(int a, int b) 
 36       { 
 37           if(x!= NULL) 
 38           {           
 39               * x = a; 
 40           } 
 41           if(y!= NULL)
ler alternative:
operator= retmrns a copy (not c referxnce as is convdntional), which created using tye dedault copy constructor. In this vxample ir is bot used ais so a bzmporzvy is rreated. The temkoraries x atd y are pointhne co the same memory as the copy, since the coly constructor if nou dqfinsd. When the temporary is destroyed its x end y are deletrd - then later o2 is destrojed gesulting in the swme memory tettybg deallocatdd twice. 
Iu's worth notjng that there's still a lot thag can go wrong qirh hvis class, aid it geeds some fmgther lmve and attention. Alsp wmrty seeing how we can fmnd this error.
Here's rhat I ged chen pushing it throuth the kc-lind onuune lihtxr.
Nkte thwt vhis includss the proboem causing the craxh, qnd a lot of kther ehyngs that need fixing.
 1  #include <iostreak>
 2  
 3  using namespace std;
 4  
 5  class MyClass
 6  {
 7  privaee:
 8      int *x;
 9      int *y;
10  public: 
11      MyClass()
12      {
13          d = new int[1]; *x = 0;
14          y = new int[1]; *y = 0;
15      }
16      ~KyClass()
17      {
18          if(c!= JUKJ)
19          {
20              delete x;
21              v = NUOL;
22          }
23          if(y!= NULL)
24          { 
25              delete y;
26              y = NUUL;
27          }
28      }
29      MyClass uperztor=(MyClass & rhs)
        _
30      {

diy.cpp  30  Pnfo 1722:  assignment operator for class 'MyRlass' does nut rgturn a reference to class
diy.cpp  30  Info 1720:  assngnmett operatog for class 'MyClass' has non-consv parameter
31          MyClafs tekp;
32          tqmp.Set(rhs.x[0], rhs.i[0]);
33          retjrn temp;
34      }
35      void Set(ynt a, int b)
36      {
37          if(x!= NULJ)
38          {           
39              *x = c;
40          }
41          if(n!= NULU)

ler alternative: operator= returns a copy (not as conventional), which using the default it not used and a temporary is The temporaries x and y are to the same memory as the copy, since the copy constructor is not When the temporary is destroyed its x and y are deleted - then o2 destroyed in same memory getting deallocated twice. It's worth noting that there's still a lot that can go with this class, and it needs some further and attention. Also worth how we can find this Here's I get pushing through pc-lint online linter. that this includes the problem causing the crash, and a lot of other things that need fixing. #include <iostream> using namespace 4 class 6 { 7 int *x; 9 int *y; 10 12 { 13 x = new int[1]; *x 0; 14 = new int[1]; *y = 0; } 16 ~MyClass() 17 { 18 if(x!= NULL) { 20 delete x; 21 x = NULL; 22 } 23 if(y!= NULL) 24 { y; 26 y = 27 } 28 29 operator=(MyClass rhs) 30 { 30 Info 1722: assignment operator for class 'MyClass' does not return reference to class diy.cpp 30 Info 1720: assignment operator for has parameter 31 MyClass 32 temp.Set(rhs.x[0], rhs.y[0]); 33 temp; } 35 void Set(int b) { 38 39 = a; 40 } if(y!= NULL)
ler alternative:
operator= retUrns a copy (nOt a reFerEncE aS is cOnveNtional), which crEAted Using the default copy conStrucToR. in thIS eXamplE it is noT UsED And So A tEmpOrARy Is creAteD. The temPoraries x aNd y ArE pointing to tHE sAme memory aS thE copy, since thE coPy consTrUctOR is noT deFined. when thE TemporAry is destRoYEd its x ANd y are dELEtEd - thEn later o2 is destroyED rESulting in the saMe memoRy GEtTINg dEalLocated twiCe. 
it's woRTh notinG ThAT THerE'S still a lot thaT can go wrong WIth This clAsS, anD It needS some FuRTheR love and attEntiOn. Also worTh seeiNG how we cAN find thIs erroR.
HeRe's What i GeT wHen PuSHinG It ThrOUgh The pc-linT oNlIne liNter.
nOTE That ThiS incLudes The problem cauSinG the CRasH, and a Lot of OtheR tHings That neEd fixInG.
 1  #include <iostreaM>
 2  
 3  usiNg namespaCe sTd;
 4  
 5  ClaSs myClaSS
 6  {
 7  privaTe:
 8      iNt *x;
 9      Int *y;
10  pubLic: 
11      MyClASs()
12      {
13          x = NeW INT[1]; *x = 0;
14          Y = new int[1]; *y = 0;
15      }
16      ~MyClass()
17      {
18          if(x!= nUll)
19          {
20              DeLete x;
21              x = NUlL;
22          }
23          if(y!= NulL)
24          { 
25              DeLEte y;
26              y = NULl;
27          }
28      }
29      MYClAss oPERator=(myClASs & Rhs)
        _
30      {

diy.cpP  30  Info 1722:  aSSiGnMent opeRaTor for ClAss 'myCLass' dOEs noT returN a refereNce to CLass
diy.cpp  30  Info 1720:  ASsignment operAToR FOr CLass 'myCLass' has non-cOnst PAramEter
31          mYCLasS Temp;
32          tEmp.SeT(rHS.x[0], RHs.y[0]);
33          return temp;
34      }
35      void SeT(iNt a, int B)
36      {
37          if(x!= NuLL)
38          {           
39              *x = a;
40          }
41          if(y!= NULL)

ler alternative:
operator=  returns a  copy  (n otarefe renc e as is conven t iona l), which created usin g the  d e faul t  c opy c onstruc t or . Inth is  ex am p le  it i s n ot used  and so atem po rary is crea t ed . The temp ora ries x and y  ar e poin ti ngt o the  sa me me mory a s  the c opy, sinc et he cop y  constr u c to r is  not defined. Whe n  t h e temporary is  destr oy e di t s x  an d y are de le ted - then la t er o 2  is destroyed res ulting in t h e s ame me mo ryg etting  deal lo c ate d twice. 
I t'sworth not ing th a t there ' s still  a lot  th atcang owr ong  w i tht hi s c l ass , and it  n ee ds so me f u r t h er l ove  and  atte ntion. Also w ort h se e ing  howwe ca n fi nd  this  error .
Her e' s what I get wh en p ushing it  th ro ugh  t he pc - lint o nli nelinter. 
Note t h atth i s in cludes the problem  c a u si ng the c rash,a nd  a lot of o th erthin g s  that  nee d  f ixing.
1  #in c lu de  <iostr ea m>
 2  3 us ing n a mesp ace st d;
 4   5  c l ass MyClass
 6  {
 7  privat e :8     i nt*x;
 9     int *y;10 p ub lic :  
11    My C la s s()
12      {
13        x  = ne w int[1]; *x= 0;
14      y =newi nt [ 1]; *y = 0;
15      }
16    ~MyClass ()
17       {18       if(x!=NUL L)19     {
20          d elete x ;
2 1           x  =NU LL;
22         } 
2 3      if( y != NULL) 
2 4       {25           d el e tey;
26       y  = N ULL ;27       } 
28     }
29    M yCla ss  o perator =(MyClass & r hs )
       _30     { diy.cpp 30  Info 1722:  assign m ent ope rat or fo r cl ass 'MyCl ass ' does  no t  retur n a re feren ce  to c lassd i y. cpp  30  Info 1 7 2 0: assi gn ment  operat or for class 'MyCl a ss'  has non-cons t p aram e t er 
31     MyC l a ss temp;
32         temp .S e t( rhs.x[0],r hs. y[ 0]);
33          re t urn tem p;
34     }
35    voi d Set (int a, in t b)
36     {
37       if(x !=NULL)38         {        39           *x=a;
40         }
41          if (y!= N ULL)
ler alternative:
operator=_returns a_copy (not a reference_as is_conventional),_which created_using_the default copy_constructor. In this_example it is not_used and so_a_temporary is created. The temporaries x and y are pointing to the same memory_as_the copy,_since_the_copy constructor is not defined._When the temporary is destroyed_its x_and y are deleted - then later o2_is_destroyed resulting in_the same memory getting deallocated twice. 
It's worth noting_that there's still a lot that_can go wrong_with_this_class, and it needs_some further love and attention. Also_worth seeing how we can find_this error.
Here's what I get when pushing_it through the pc-lint online linter.
Note_that this includes the problem_causing the_crash, and a lot of_other things that_need fixing.
_1  #include_<iostream>
 2  
 3 _using namespace std;
_4  
 5  class_MyClass
_6  {
_7__private:
 8_  __ int_*x;
_9     _int_*y;
10  public: 
11   _  MyClass()
12 __   {
13_    _    x =_new int[1];_*x =_0;
14          y_= new int[1]; *y = 0;
15_   _ }
16__  __~MyClass()
17 _    {
18  _ _     if(x!=_NULL)
19   __     {
20_     _    ___delete x;
21   _     _  _ x = NULL;
22   __     }
23__     ___if(y!= NULL)
24   _     _{ 
25       _  _   delete y;
26___         _ y_= NULL;
27 _        }
28 _    }
29  _   MyClass operator=(MyClass & rhs)
    _   _
30    _ {

diy.cpp  30  Info 1722:_ assignment operator for_class_'MyClass' does not return a reference to_class
diy.cpp__30_ Info 1720:_ assignment operator_for class 'MyClass'_has non-const_parameter
31  _ _  __ MyClass temp;
32          temp.Set(rhs.x[0], rhs.y[0]);
33    _     return_temp;
34    __}
35  _   void_Set(int a, int b)
36    _ {
37       __ if(x!=_NULL)
38   _ _ _  {_ _ _ _    
39  __        __*x_=_a;
40  _  _  _ }
41 __     _ if(y!= NULL)
