Advertisement
kyerkun

Untitled

Mar 20th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C++ Compiler.
  4. Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10. #include <vector> ;
  11. using namespace std;
  12. class Q
  13. {
  14. public:
  15. int x;
  16. Q();
  17. Q(const Q& q);
  18. Q& operator=(const Q& q);
  19. };
  20. Q::Q(): x(0)
  21. {
  22. cout << "1";
  23.  
  24. }
  25. Q::Q(const Q& q)
  26. {
  27. cout << "2";
  28. x = q.x;
  29.  
  30. }
  31. Q& Q::operator=(const Q &q)
  32. {
  33. cout <<"3";
  34. x = q.x;
  35. return *this;}
  36. void foo(Q q4, Q& q5)
  37. {
  38. Q q6 = q4;
  39. q6 = q5;
  40.  
  41. }
  42. void bar()
  43. {
  44. Q q1;
  45. Q q2 = q1;
  46. q1 = q2;
  47. Q q3(q1);
  48. foo(q1, q2);
  49.  
  50. }
  51.  
  52. int main(){
  53. bar();
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement