Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class C {
- private:
- static int counter;
- public:
- C() {
- ++counter;
- if (counter == 1)
- std::cout << "constructor C()\n";
- }
- C(const C& other) {
- ++counter;
- if (counter == 1)
- std::cout << "constructor C(const C&)\n";
- }
- C& operator = (const C& other) {
- return *this;
- }
- C& operator = (C&& other) {
- return *this;
- }
- ~C() {
- --counter;
- if (counter == 1)
- std::cout << "destructor C()\n";
- }
- };
- int C::counter = 0;
Advertisement
Add Comment
Please, Sign In to add comment