fortran 不同返回值类型的同名函数

2025-04-06 14:33:25
推荐回答(1个)
回答1:

module sub
interface xxx
module procedure aaa
module procedure bbb
end interface
contains

Integer Function aaa(x)
integer x
aaa = 3 * x
end function aaa

real Function bbb(x)
real x
bbb = 3.0 * x
end function bbb

end module sub

program u
use sub
write(*,*) xxx(3) , xxx(3.0)
end program u