next up previous contents
Next: Linear Systems of Algebraic Up: Elements of object-oriented programming Previous: Derived Type Constructors   Contents

Generic Procedures

 
module gi  
interface plus1  
 module procedure iplus1  
 module procedure rplus1  
 module procedure dplus1  
end interface ! plus1  
contains  
integer function iplus1(x)  
   integer, intent(in) :: x  
   iplus1 = x + 1  
end function iplus1     
real function rplus1(x)  
   real, intent(in) :: x  
   rplus1 = x + 1.0  
end function rplus1     
double precision function dplus1(x)  
   double precision, intent(in) :: x  
   dplus1 = x + 1.0d0  
end function dplus1     
end module gi

The call plus1(2) will return an integer result, while plus1(2.0) will return a real result.


Adrian Sandu 2001-08-26