Guest User

Untitled

a guest
Dec 12th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. // Copy Constructor
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. class Myclass {
  7. public:
  8. Myclass() {
  9. cout << "default constructor" << endl;
  10. }
  11.  
  12. Myclass(const Myclass &r)
  13. {
  14. cout << "***********************************" << endl;
  15. cout << "copy constructor" << endl;
  16. cout << "this = " << this << endl;
  17. cout << "&r = " << &r << endl;
  18. cout << "***********************************" << endl;
  19. }
  20.  
  21. };
  22.  
  23.  
  24. void gfunc(Myclass m)
  25. {
  26. cout << "gfunc cagrildi" << endl;
  27. cout << "&m = " << &m << endl;
  28. cout << "---------------------------------------------" << endl;
  29.  
  30. }
  31.  
  32.  
  33. int main()
  34. {
  35. Myclass m1;
  36.  
  37. cout << "&m1 = " << &m1 << endl;
  38. gfunc(m1);
  39.  
  40.  
  41. return 0;
  42. }
  43.  
  44. /*
  45. default constructor
  46. &m1 = 0x7ffeeeeb0468
  47. ***********************************
  48. copy constructor
  49. this = 0x7ffeeeeb0460
  50. &r = 0x7ffeeeeb0468
  51. ***********************************
  52. gfunc cagrildi
  53. &m = 0x7ffeeeeb0460
  54. ---------------------------------------------
  55. */
Add Comment
Please, Sign In to add comment