Hi
I have encountered a strange behavior of my c++ code when calling a destructor. Basically, I do the following:
I have a pointer to an object v of type diagVertex.
Then I delete it:
delete v; v=NULL;
This should call the destructor of diagVertex:
diagVertex::~diagVertex()
{
____diagTable->popVertex(this);
}
The method popVertex removes the object from a data base called diagTable. Now, what is weird is that it is only removed sometimes. On some occasions, it remains in the database non the less. And, using breakpoints, I notice that the function popVertex is not always called upon deleting v, but only sometimes. However, if I change my code and call the pop function before deleting, then it works like a charm, i.e.:
v->diagTable->popVertex(v);
delete v; v=NULL;
and
diagVertex::~diagVertex()
{
}
--------
This is puzzling to me to say the least. Is there something I have gotten wrong about the destructor? Does anyone have an idea about what I am doing wrong?
Best
//
Johan
I have encountered a strange behavior of my c++ code when calling a destructor. Basically, I do the following:
I have a pointer to an object v of type diagVertex.
Then I delete it:
delete v; v=NULL;
This should call the destructor of diagVertex:
diagVertex::~diagVertex()
{
____diagTable->popVertex(this);
}
The method popVertex removes the object from a data base called diagTable. Now, what is weird is that it is only removed sometimes. On some occasions, it remains in the database non the less. And, using breakpoints, I notice that the function popVertex is not always called upon deleting v, but only sometimes. However, if I change my code and call the pop function before deleting, then it works like a charm, i.e.:
v->diagTable->popVertex(v);
delete v; v=NULL;
and
diagVertex::~diagVertex()
{
}
--------
This is puzzling to me to say the least. Is there something I have gotten wrong about the destructor? Does anyone have an idea about what I am doing wrong?
Best
//
Johan