本帖最后由 LEM 于 2021-4-8 22:31 编辑
[Fortran] 纯文本查看 复制代码 MODULE typedef
IMPLICIT NONE
TYPE :: tree
INTEGER,ALLOCATABLE :: mat(:)
INTEGER :: a
TYPE(tree),POINTER :: ltree
TYPE(tree),POINTER :: rtree
END TYPE
END MODULE typedef
PROGRAM test
USE typedef
IMPLICIT NONE
TYPE(tree),POINTER :: root => NULL()
TYPE(tree),POINTER :: temp1 => NULL(),temp2 => NULL()
ALLOCATE(root,temp1,temp2)
ALLOCATE(temp1%mat(5),temp2%mat(6))
temp1%mat = 1
temp2%mat = 2
temp1%a = 1
temp2%a = 2
root%ltree => temp1
root%rtree => temp2
END PROGRAM test
我在24行添加断点,发现root%ltree%mat没有被赋值(如下图所示)
请问各位大神,是什么原因呢
|