小编Ant*_*iro的帖子

从扩展类型的实例打印父类型的成员

场景(见下面的代码):考虑一些 Fortran 模块my_module,它包含两个派生类型的定义:test(parent) 和sub_test(extends test, subclass)。除了两个构件ab父类的,sub_test定义了一个新成员c。最终,该模块my_module将用于某些程序中my_program

module my_module

implicit none

private
public :: test, sub_test

type :: test
  integer :: a = 1
  integer :: b = 2
end type test

type, extends(test) :: sub_test
  integer :: c = 3
contains
  procedure, public :: increment
end type sub_test

contains

subroutine increment (this)
class(sub_test) :: this
this % a = this …
Run Code Online (Sandbox Code Playgroud)

linux debugging fortran gdb gfortran

5
推荐指数
0
解决办法
120
查看次数

标签 统计

debugging ×1

fortran ×1

gdb ×1

gfortran ×1

linux ×1