I tried to create a garbage collector in C ++, I developed it as a base class for all mine called garbageCandidate, which contains a static vector containing pointers to garbageCandidate, with each instance of garbageCollector with clicking "this" on the vector.
Then a static function appears and all pointers in the static vector are deleted.
At the very beginning of the delete function (delete with the first pointer) I get an error message in which the delete was used on an invalid pointer ...
Is this related to static / dynamic binding? I mean: the delete operator cannot act as expected, since I call delete in the father class, and is it really a child?
Can this be avoided to create virtual destructors? (or virtual delete function)?
or am I missing something?
ps: all objects used for the test, where they are created dynamically.
source
share