Skip to content

RenkeHuang/oop_in_fortran

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object-Oriented Fortran

Fortran 2003 introduced several object-oriented programming features, including:

  1. Derived Type Extension: Allows you to define a new type that extends an existing type using extends.
  2. Type-bound Procedures: Functions or procedures bound to a specific type, which can be overridden in derived types.
  3. Inheritance and Polymorphism: Supports polymorphic types and inheritance, enabling object-oriented design patterns.
  4. Interfaces for Type-bound Procedures: Using procedure and interface blocks within derived types for defining virtual functions and interfaces.

Example from source:

type, extends(shape_m), public :: triangle_m
    contains
        procedure :: get_area
end type triangle_m

Note

  • type, extends(shape_m), public :: triangle_m: Defines triangle_m as a derived type that extends shape_m, inheriting its properties and methods.
  • contains and procedure :: get_area: contains signifies that triangle_m will have type-bound procedures, and procedure :: get_area binds the get_area procedure to this type, which overridea the get_area in shape_m if it exists there.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published