- UID
- 3599
- 性别
- 保密
齊天大聖
- 积分
- 778
- F 币
- 433 元
- 最后登录
- 2021-10-14
- 贡献
- 266 点
- 注册时间
- 2018-11-8
- 权杖
- 0 枚
惯用编译器:GFortran / G77 for Linux
专家
齊天大聖
- F 币
- 433 元
- 贡献
- 266 点
|
我重现了一下,其实代码上的问题,个人感觉不在类的继承上。而在于printSum上。
module m_father
implicit none
private
type,public :: t_father
procedure(temp),nopass,pointer :: p
end type t_father
abstract interface
function temp(a) result(out)
implicit none
integer,intent(in) :: a
integer :: out
end function temp
end interface
end module m_father
module m_son
use m_father
implicit none
private
type,extends(t_father),public :: t_son
integer :: a
end type t_son
end module m_son
program main
use m_son
implicit none
type(t_son) :: one
one%p=>jiecheng
print*,one%p(5)
contains
function jiecheng(a) result(out)
implicit none
integer,intent(in) :: a
integer :: out
integer :: i
out=1
do i=2,a
out=out*a
end do
end function jiecheng
end program main
我测试了,这样是没有问题的 |
|