Take the tour ×  I need to mix Fortran and C++ together. I have
written C++ class. I am able to call C++ public function thanks
to extern "C" function that makes call to C++ library.  This
function creates some instances of this C++ classe. When this
function ends, I want to keep those instances in memory to call
them after. But destruction my instances are called
automatically.  I don't want to use those instances with Fortran
but to use them in other wrapped C++ function. I can't use
iso_c_binding or any Fortran 2003 function (unfortunately).  Do
you have any simple ideas to keep instances in memory ?  Thanks
in advance.  share|improve this question new? (Also, what does
this have to do with Fortran?) –  melpomene Dec 10 '12 at 17:02
So they are being created on the stack, and then destroyed when
your function completes? Put them on the heap (using new, but
best to avoid using it directly with some wrapper), and then
save pointers to them somewhere. –  BoBTFish Dec 10 '12 at 17:02
add comment  1 Answer  up