CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   C explicit call of destructor (https://www.cfd-online.com/Forums/openfoam/60777-c-explicit-call-destructor.html)

maka August 20, 2008 08:30

After I destroy a fvMesh objec
 
After I destroy a fvMesh object:
mesh.~fvMesh();
or
mesh.fvMesh::~fvMesh();

I could still use mesh variable with no complains from the compiler?! Did I do something wrong?

Thanks.

nadine August 20, 2008 09:47

>After I destroy a fvMesh obje
 
>After I destroy a fvMesh object:
>mesh.~fvMesh();
>or
>mesh.fvMesh::~fvMesh();

I would never have thought of using the destructor function this way :-o

Not the destructor function destroys an object, but when an object is destroyed, then the destructor is called.

>I could still use mesh variable with no complains >from the compiler?!

There are several objects with an empty destructor, so calling it has no effect. But generally its a very, very bad idea.

>Did I do something wrong?

Depends on your point of view. I suggest doing something right would be to learn C++.

Nadine

maka August 20, 2008 11:19

"Note that explicit call of d
 
[Stroustrup2000 p. 256] "Note that explicit call of destructors ... should be avoided wherever possible. Occasionally, they are essential." Thanks for your help.


All times are GMT -4. The time now is 09:22.