|
以下代码可以正常编译运行
[Fortran] 纯文本查看 复制代码 008 | procedure ( sub ) , pointer :: p = > null ( ) |
010 | procedure , pass :: point_new |
011 | procedure , pass :: printSum |
015 | subroutine sub ( me , x , f ) |
017 | class ( point ) , intent ( inout ) :: me |
018 | real , dimension ( : ) , intent ( in ) :: x |
023 | subroutine point_new ( me , x , y ) |
024 | class ( point ) , intent ( inout ) :: me |
030 | end subroutine point_new |
032 | subroutine printSum ( me , pp ) |
033 | class ( point ) , intent ( inout ) :: me |
038 | call me % p ( [ me % x , me % y ] , f ) |
040 | end subroutine printSum |
041 | end module super_class |
048 | type , public , extends ( point ) :: point 3 d |
051 | procedure , pass :: point 3 d_new |
052 | procedure , pass :: printSum |
056 | subroutine sub ( me , x , f ) |
058 | class ( point ) , intent ( inout ) :: me |
059 | real , dimension ( : ) , intent ( in ) :: x |
064 | subroutine point 3 d_new ( me , x , y , z ) |
065 | class ( point 3 d ) , intent ( inout ) :: me |
070 | call me % point % point_new ( x , y ) |
072 | end subroutine point 3 d_new |
074 | subroutine printSum ( me , pp ) |
075 | class ( point 3 d ) , intent ( inout ) :: me |
080 | call me % p ( [ me % x , me % y , me % z ] , f ) |
082 | end subroutine printSum |
093 | call a % point_new ( 1.0 , 1.0 ) |
096 | call b % point 3 d_new ( 2.0 , 2.0 , 2.0 ) |
099 | subroutine sss ( me , x , f ) |
100 | class ( point ) , intent ( inout ) :: me |
101 | real , dimension ( : ) , intent ( in ) :: x |
但是将子类模块中的抽象接口相关语句注释后
编译将报错
按理说通过use语句
子类模块可以导入父类模块相关内容 从而减少代码量
为何子类模块必须要把父类模块的抽象接口代码重写一遍呢?
|
|