I've been trying to create a garbage collector in c++, i've designed it as a base class to all of mine, called garbageCandidate, which holds a static vector containing pointers to garbageCandidate with every garbageCollector instance pushing "this" on the vector.
Then a static function comes and delete all the pointers in the static vector.
At the very begining of the deleting function (delete on first pointer) i get an error stating delete was used on invalid pointer...
Does this have to do with static/dynamic binding? I mean : is the delete operator unable to act as expected since i call delete on a "father" class and it is in fact a child ?
Could a way of avoiding this be to create virtual destructors? (or a virtual delete function)?
or did i completely missed something?
ps:all objects used for test where created dynamically.