【发布时间】:2019-01-17 13:21:14
【问题描述】:
假设您有两个具有不同接口的子例程,并且您有两种类型,每种类型对应于一个过程。
type, abstract :: base
contains
procedure :: pointer_to_routine
end type base
type, extends(base) :: first_case
contains
procedure :: pointer_to_routine => first_case_routine
end type first_case
type, extends(base) :: second_case
contains
procedure :: pointer_to_routine => first_sec_routine
end type second_case
所以这不是有效的 Fortran 代码,但这是我想做的一种想法。如果例程具有相似的接口,我可以在基本声明类型中定义abstract interface 和deferred 属性。
但由于我的两个例程有不同的接口,我不确定这会如何解决。
基本上,一个例程需要比另一个例程更多的输入,因此一种解决方案是将剩余的输入添加为只是虚拟输入,尽管这可能会导致一些混乱,我想知道是否有更方便的解决方案。
【问题讨论】:
标签: oop fortran overloading intel-fortran