Derived Data Types - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Derived Data Types

Description:

Example of Data Definition. TYPE :: employee. CHARACTER (20) :: lastName ... Components of derived data types can be used independently just as any other data type. ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 11
Provided by: cs41
Category:
Tags: data | definition | derived | of | types

less

Transcript and Presenter's Notes

Title: Derived Data Types


1
Chapter 12
  • Derived Data Types

2
Derived Data Types
  • User-defined data types used to meet the
    requirements of a specific problem.
  • Made of a combination of intrinsic data types
    (integer, real, character, logical, or complex)
    and/or other user-defined data types.

3
Form of Derived Data Type Definition
  • General form
  • TYPE type_name
  • component definitions
  • . . .
  • END TYPE type_name

4
Example of Data Definition
  • TYPE employee
  • CHARACTER (20) lastName
  • CHARACTER (20) firstName
  • CHARACTER (10) workID
  • INTEGER age
  • REAL salary
  • END TYPE employee

5
Examples of Data Defined as a Derived Type
  • TYPE (employee) harry, joe
  • TYPE (employee), DIMENSION (200)
  • firstShift

6
Structure Constructor
  • Each item of a derived data type is known as a
    structure.
  • To create unnamed constants of a derived data
    type, use a structure constructor.
  • A structure constructor consists of the name of
    the type followed by the components of the
    derived data type in parentheses.

7
Example of Structure Constructor
  • harry employee (Jones, Harry,
  • 425, 45,
    1200.00)
  • joe employee (Smith, Joe, 3356,
  • 36, 980.00)

8
Example of derived data type within another
derived data type
  • TYPE payroll
  • TYPE (employee) programmer
  • CHARACTER (20) classification
  • REAL vacationHours
  • REAL sickLeave
  • REAL payrollHours
  • END TYPE
  • TYPE (payroll), DIMENSION(10) costCenter

9
Component Selector
  • Components of derived data types can be used
    independently just as any other data type.
  • The component is specified by a component
    selector that consists of the name of the
    variable followed by the then the component
    name.
  • Example joeage 38

10
Addressing derived data arrays
  • To address a component within an array of a
    derived data type, the subscript is placed after
    the array name and prior to the .
  • Example costcenter(2) payrollHours 30
Write a Comment
User Comments (0)
About PowerShow.com