Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Complex Inheritance

holysword
Novice
329 Views
Hi everybody,
I am wondering if there is any way to implement this kind of thing:
[fortran]  type,abstract :: c_father_b
    ...
  end type c_father_b
!-------------------------------
  type, extends(c_father_b) :: c_child_b
    ...
  end type c_child_b
!-------------------------------
  type,abstract :: c_father_a
    class(c_father_b), pointer :: ptr_to_b
  end type c_father_a
!-------------------------------
  type, extends(c_father_a) :: c_child_a
    type(c_child_b), pointer :: ptr_to_b
  end type c_child_a[/fortran]
The reason is that I have a main abstrac class (A) which have a pointer to another abstract class(B). However, in SOME of the children of A will ALWAYS have this pointer to a specific children of B. The way I have it implemented now is using the pointer for c_father_a and having type select all around the code, which we must agree, its not beautiful at all. Is there any workaround for that and/or a plan to the implementation of this feature?
Thanks in advance!
0 Kudos
0 Replies
Reply