Advertisement
Dzham

Untitled

Feb 27th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int counter1 = 0;
  4. class C {
  5. int c = counter1++;
  6. public:
  7. C() {
  8. std::cout << "constructor C() " << c << "\n";
  9. }
  10.  
  11. C(const C& other) {
  12. std::cout << "constructor C(const C&) " << c << "\n";
  13. }
  14.  
  15. C(C&& other) {
  16. std::cout << "constructor C(const C&&) " << c << "\n";
  17. }
  18.  
  19. C& operator = (const C& other) {
  20. std::cout << "operator = (const C&) " << "\n";
  21. return *this;
  22. }
  23.  
  24. C& operator = (C&& other) {
  25. std::cout << "operator = (const C&&)\n";
  26. return *this;
  27. }
  28.  
  29. ~C() {
  30. std::cout << "destructor C() " << c << "\n";
  31. }
  32. };
  33.  
  34. int counter2 = 0;
  35. class D {
  36. private:
  37. C c1;
  38. const C& c2;
  39. const C* c3;
  40. int c = counter2++;
  41.  
  42. public:
  43. D(const C& arg1, const C& arg2, const C* arg3) :
  44. c1(arg1),
  45. c2(arg2),
  46. c3(arg3) {
  47. std::cout << "constructor D(const C&, const C&, const C*) " << c << "\n";
  48. }
  49.  
  50. ~D() {
  51. std::cout << "destructor D() " << c << "\n";
  52. }
  53. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement