What do you mean by “script” when it comes to C++?
You may be best off trying to consume the " C++ library" directly from “the main C++ xx” rather than trying to “trying to share an object created by the Fortran code.”
By the way, the language since the 1991 publication of its ISO IEC standard revision goes by Fortran, not FORTRAN
.
And note the Fortran
standard supports interoperability with a companion C processor, but there is no recognized support with C++. Thus you are constrained with a middle layer of C, via “extern C” in C++ and the facilities toward interoperability with C and its requirements in Fortran.
If you retain a necessity to go the Fortran
route in your C++ code(s), if you can mock up a scenario of the data involved and what operations (methods) need to be performed on the data, readers can suggest some code design options. In the meantime, you can review this thread closely for some of the options toward working with Fortran from C++.