我试图在模块内部创建一个抽象类型
type, abstract :: AbsType
contains
procedure (Compute_AbsSize), deferred :: AbsSize
end type AbsType
abstract interface
function Compute_AbsSize(this)
import AbsType
double precision Compute_AbsSize
class(AbsType)::this
end function Compute_AbsSize
end interface
type, extends(AbsType) :: ConcrType
type(Var), dimension(4) :: Nodes ! coming from a module
contains
procedure :: AbsSize => ConcrTypeSize
end type ConcrType
contains
function ConcrTypeSize(this)
double precision ConcrTypeSize
class (ConcrType):: this !
end function ConcrTypeSize
事实证明,如果我写
function ConcrTypeSize(TheConcrType)
double precision ConcrTypeSize
class (ConcrType):: TheConcrType !
end function ConcrTypeSize
编译器(gcc)抱怨 TheConcrType 应该与延迟函数的变量具有相同的名称。我找不到此信息,有人知道我为什么必须这样做,这是正确的吗?
编辑:我将问题的最后一部分移到了 这个新问题