【发布时间】:2018-04-25 22:24:04
【问题描述】:
我说“扩展”是因为,原谅我,我不确定这里正确的 OOP 术语是什么。我并不完全想覆盖一个函数。我希望继承派生类型中的函数完成同名函数在父类型中所做的所有工作,然后添加到该函数中。我想要类似的东西:
module foo1
type :: bar1
contains
procedure :: f1
end type bar1
contains
subroutine bar1()
! do stuff
end subroutine bar1
end module foo1
module foo2
use foo1
type, extends(bar1) :: bar2
contains
procedure :: f1
end type bar2
contains
subroutine f1()
! call parent f1
! do other stuff
end subroutine f1
end module foo2
有没有办法在 Fortran 中做到这一点?
【问题讨论】:
标签: inheritance fortran derived-types