Amonin

Untitled

Dec 11th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. class C {
  3. private:
  4.     static int counter;
  5.  
  6. public:
  7.     C() {
  8.         ++counter;
  9.         if (counter == 1)
  10.             std::cout << "constructor C()\n";
  11.     }
  12.  
  13.     C(const C& other) {
  14.         ++counter;
  15.         if (counter == 1)
  16.             std::cout << "constructor C(const C&)\n";
  17.     }
  18.  
  19.     C& operator = (const C& other) {
  20.         return *this;
  21.     }
  22.  
  23.     C& operator = (C&& other) {
  24.         return *this;
  25.     }
  26.  
  27.     ~C() {
  28.         --counter;
  29.         if (counter == 1)
  30.             std::cout << "destructor C()\n";
  31.     }
  32. };
  33. int C::counter = 0;
Advertisement
Add Comment
Please, Sign In to add comment