Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A {
- public:
- static int count; // Maybe set this to static?
- A() { // "2) It doesn't "manage" any pointers - nor does it take pointers as arguments." ... so no arguments here...?
- count++; // "The two constructors need to increase the count of objects"
- }
- A(A &p)
- {
- count++; // "The two constructors need to increase the count of objects"
- }
- A& operator=(const A &p)
- {
- if (&p != this) {
- // ?? count is static, so just increase it?
- count++;
- }
- return *this;
- }
- ~A() {
- count--; // "the destructor needs to decrease [the count of objects]."
- if (count == 0)
- {
- // ?? No pointers taken as an argument, so I have nothing to delete
- }
- }
- };
- int A::count = 0;
Add Comment
Please, Sign In to add comment