- #1
santanaa
- 3
- 0
Hi I have a little issue with f90.
I am a c++ programmer but I have to use fortran for this project.
f90 the compiler does seem to distinguish between methods from user defined types. I have two types one "has a" instance of the other. Both have a methods named Print (with different typed arguments and in different modules). I want both of my user efined types to have the method named Print. The compiler won't let me define both!
here is an example
here is the error
Howe can I have both user dfeind type have a function named Print?
I am a c++ programmer but I have to use fortran for this project.
f90 the compiler does seem to distinguish between methods from user defined types. I have two types one "has a" instance of the other. Both have a methods named Print (with different typed arguments and in different modules). I want both of my user efined types to have the method named Print. The compiler won't let me define both!
here is an example
Code:
module BoxModule
type Box
...
end type
contains
subroutine Print(b)
type(Box) b
...
end subroutine
end module
module OtherModule
type Other
...
type(Box) b
...
end type
contains
subroutine Print(o) ! <----------------------------- compiler doesn't like this
type(Other) o
...
Print(o%b)
...
end subroutine
end module
here is the error
Code:
subroutine Print(c)
1
use BoxModule
2
Error: Procedure 'print' at (1) is already defined at (2)
Howe can I have both user dfeind type have a function named Print?