2
在下面的一段代码中,具有私有变量(名称)和该变量的访问函数的抽象类型(应该由所有派生类型定义)在模块:在不同模块中抽象类型的扩展
module baseTypeModule
type, abstract :: baseType
private
character(len=maxLengthCompLabel) :: Name = "" ! Component name
contains
procedure, non_overridable :: getName ! Access functio to Name (read only)
end type baseType
contains
character(len=100) function getName(this)
implicit none
class(baseType), intent(in) :: this
getName = this % Name
end function getName
end module baseTypeModule
由于有很多其他的变量和函数在每个派生类型,我想在不同的模块来定义每个派生类型。
Fortran中是否有方法告诉编译器,我希望只有派生类型的baseType才能够更改变量Name?