can a type member which is a type be a target?
Suppose I have the following setup
type BarType
integer :: i
end type
type FooType
type(BarType) :: bar
end type
I want to have another type
type BazType
type(BarType), pointer :: barPtr
end type
and set barPtr
to point to foo%bar
. To do this I would have to declare type(BarType开发者_StackOverflow社区), target :: bar
, but I got an error. I didn't investigate further, and decided to change strategy, but just for curiosity, do you know if this is allowed ?
I'm not an expert on the standard, but the way I read it, a derived-type component can not have the target
attribute; if you want to associate a pointer with such a component, you have to declare the parent object as target
.
精彩评论