Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. StringBad & StringBad::operator=(const StringBad & st)
  2.  
  3. {
  4.  
  5. cout<<"**********USANDO O OPERADOR************";
  6.  
  7. if (this == &st) // object assigned to itself
  8.  
  9. return *this; // all done
  10.  
  11. delete [] str; // free old string
  12.  
  13. len = st.len;
  14.  
  15. str = new char [len + 1]; // get space for new string
  16.  
  17. std::strcpy(str, st.str); // copy the string
  18.  
  19. return *this; // return reference to invoking object
  20.  
  21. }
  22.  
  23. StringBad headline1("Celery Stalks at Midnight");
  24. StringBad knot;
  25.  
  26. knot =(headline1);
  27.  
  28. cout << "knot: " << knot << endl;
  29.  
  30. cout << "Exiting the block.n";
  31.  
  32. cout << "End of main()n";
  33.  
  34. knot = headline1;
  35.  
  36. cout << "knot: " << knot = headline1 << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement