fork download
  1. #include <cstring>
  2. #include <iostream>
  3.  
  4. class quee
  5. {
  6. private:
  7. char *p;
  8. int next;
  9.  
  10. public:
  11. quee() :
  12. p(new char[2] {'a', '\0'}),
  13. next(0)
  14. {
  15.  
  16. }
  17.  
  18. quee(const quee &obj)
  19. {
  20. std::cout << "quee(const quee &obj)" << std::endl;
  21. p = new char[strlen(obj.p)];
  22. strcpy(p, obj.p);
  23. next = obj.next;
  24. }
  25.  
  26. quee &operator=(quee &obj)
  27. {
  28. std::cout << "quee &operator=(quee &obj)" << std::endl;
  29. delete[] p;
  30. p = new char[strlen(obj.p) + 1];
  31. strcpy(p, obj.p);
  32. next = obj.next;
  33. return *this;
  34. }
  35. };
  36.  
  37. int main()
  38. {
  39. quee a;
  40. quee b = a;
  41. b = a;
  42. return 0;
  43. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
quee(const quee &obj)
quee &operator=(quee &obj)