Type detection: Difference between revisions
→{{header|Fortran}}
Line 567:
=={{header|Fortran}}==
Fortran 2008 and later can do this with general types, using
Polymorphism involving types derived from a base type can be done in Fortran 2003 and later.
There is also, in modern Fortran, an overload mechanism that can be used to give procedures that take different types the same name
Legacy versions of Fortran have ways to store data of one type in a variable declared as some other type, and this mechanism could be employed.
Below I use ‘class(*)’, which seems best to satisfy the task description. The ‘print_text’ subroutine is used to print a string, an array of strings, and an input file.▼
===Unlimited type polymorphism===
▲Below I use ‘class(*)’
<lang fortran>program input_type_detection_demo
|