I've been searching for an answer here on the board about destructors. I found this
Is that a reason why my destructors are called twice?The destructor is called either when the variable goes out of scope, or you call delete on a pointer variable.
I have a base class and a derived class. I construct 3 instances of base class and three of derived class. The destructor gets called three times on the derived clas (interleaving with destructor for the base class, naturally), and then the base class destructor is called again 3 times.
I do have pointers in both base and derived classes and I use delete on them in my own copy constructors. But if the deconstructor was called on that delete [], then my cout << "destructor" would appear much earlier in the output, right?
I've been studying C++ for 8 weeks now, and having C as base does not help at all. It is more confusing that I would expect...