- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In our code we sometimes need to iterate over a list of polymorphic variables. To do that we create a derived type as a container such as:
type myContainerT
class(myExtendedBaseType), allocatable :: var
end type myContainerT
Now, myContainerT will not be extended, but var is polymorphic.
The question is, whether myContainerT is polymorphic too because it has polymorphic member variables and thus should be declared with class instead of type e.g. in dummy argument lists.
Even though the ifort seems to not care about that, any explanation of what goes on in the background would be greatly appreciated.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, the objects and dummy argument references to this 'container' type need not be declared as 'CLASS', they can be 'TYPE'.
In fact, programs should be very judicious in their use of the polymorphic option with 'CLASS' and only make use of it when it serves a valuable purpose with respect to program design and logic.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, the objects and dummy argument references to this 'container' type need not be declared as 'CLASS', they can be 'TYPE'.
In fact, programs should be very judicious in their use of the polymorphic option with 'CLASS' and only make use of it when it serves a valuable purpose with respect to program design and logic.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page