Research Article
Emulating Multiple Inheritance in Fortran 2003/2008
Listing 3
Additional level of abstraction used to incorporate all classes to be inherited.
| (1) module facade_concrete | | (2) use object_distribution_concrete, only: object_distribution | | (3) use object_computation_concrete, only: object_computation | | (4) implicit none | | (5) private | | (6) public :: facade | | (7) type, extends(object_distribution):: facade | | (8) type(object_computation):: my_flop | | (9) contains | | (10) procedure:: FlopCount | | (11) end type | | (12) interface facade | | (13) module procedure constructor | | (14) end interface | | (15) contains | | (16) type(facade) function constructor() | | (17) constructor%object_distribution=object_distribution() | | (18) constructor%my_flop=object_computation() | | (19) end function | | (20) subroutine FlopCount(this) | | (21) class(facade), intent(in):: this | | (22) call this%my_flop%FlopCount() | | (23) end subroutine | | (24) end module |
|