While the vector of pointers is deleted at the end of the program, I am having 3 error leaks which seem to correspond with the 3 types of accounts I have. That being said, if I delete the pointer after putting it into the vector, it deletes the entry in the vector as well (which I expected)

My issue didn't have as much to do with the vector as it did the destructors of the classes. As I had not defined a virtual destructor only the base class was being erased, leaving behind fragments of the derived classes. There is no no memory leak after adding this.

You wrote this is about the only thing I think it could be - why do you think that this could be the only cause? Before looking at your vector more closely, consider other places using new and malloc.
–
Frerich RaabeSep 21 '12 at 8:16

I don't use malloc anywhere, anywhere else with "new" has a delete after it, everywhere except for here.
–
user1623990Sep 21 '12 at 8:22

Btw, the reason the vector doesn't delete the pointers for you, is that if it did then you wouldn't be able to store pointers that weren't allocated with new, or that you didn't want deleted when the vector was destroyed.
–
Steve JessopSep 21 '12 at 8:38

@user1623990 you should use std::unique_ptr then, and store that in your std::vector or use the boost::vector_ptr
–
Tony The LionSep 21 '12 at 8:18

4

@MartinJames: Since the stack isn't shared between threads, stack-based objects need no locking, and thus make threading easier. Besides that, they are easier to deal with even in single-threaded code, and should thus be t he default.
–
sbiSep 21 '12 at 9:44

3

@MartinJames: "heap objects can be safely and easily be communicated by pointer" What?
–
sbiSep 21 '12 at 10:28