1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
module Foo_mod
implicit none
type Foo
character(len=:), allocatable :: buffer
contains
procedure :: get
end type Foo
contains
function get(f) result(p)
class (Foo), target, intent(in) :: f
character(len=:), pointer :: p
p => f%buffer
end function get
end module Foo_mod
program main
use Foo_mod
implicit none
character(len=:), pointer :: p
type (Foo) :: f
f%buffer = 'cat'
p => f%get()
if (.not. (p == 'cat')) then
stop 1
end if
end program main
|