Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29252 Discussions

Is there any method to call C++ class

weichao
Beginner
739 Views
I have some codes were written by C++. There are many CLASS definition. Is there any method could use variables and fumctions of C++ CLASS. Or I have to modify C++ code to C.
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
739 Views
You cannot call C++ class members directly, at not easily. You don't have to rewrite the C++ code, but you can write either C-style wrappers or C++ static class member functions around C++ class methods. These are callable from Fortran as they don't expect this as the first hidden argument. You have to find the means to pass this (i.e. pointer to class object) around -- usually, you pass this from C++ to Fortran as an INTEGER, and pass it back to above-mentioned wrapper unmodified.

See this thread for a sample.

Jugoslav

Jugoslav
0 Kudos
Reply