B
beliavsky
If I have a file foo.cpp defining functions f1, f2, f3, etc. and a
corresponding header file foo.h, I can #include foo.h in another source
file and then use those functions. This gives me access to ALL the
functions in foo.cpp. What if I only want to use f1 and f2 and do not
want to "pollute" the namespace with all the functions defined in foo?
I could just copy the function prototypes of f1 and f2 to the source
file calling them, but it better to avoid duplicating code.
Using modules in Python and Fortran 90 one would write
from foo import f1,f2 # Python
use foo, only: f1,f2 ! Fortran
corresponding header file foo.h, I can #include foo.h in another source
file and then use those functions. This gives me access to ALL the
functions in foo.cpp. What if I only want to use f1 and f2 and do not
want to "pollute" the namespace with all the functions defined in foo?
I could just copy the function prototypes of f1 and f2 to the source
file calling them, but it better to avoid duplicating code.
Using modules in Python and Fortran 90 one would write
from foo import f1,f2 # Python
use foo, only: f1,f2 ! Fortran