
Data Structure

This illustrates a data structure, a means of storing data within a program.

You may see other such structures in the Data Structures category.


Task

Create a compound data type:

  Point(x,y) 



A compound data type is one that holds multiple independent values.



Related task

   Enumeration


See also

 Array
 Associative array: Creation, Iteration
 Collections
 Compound data type
 Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
 Linked list
 Queue: Definition, Usage
 Set
 Singly-linked list: Element definition, Element insertion, List Traversal, Element Removal
 Stack


INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit
 
DEFINE REALPTR="CARD"
TYPE PointI=[INT x,y]
TYPE PointR=[REALPTR rx,ry]
 
PROC Main()
  PointI p1
  PointR p2
  REAL realx,realy
 
  Put(125) PutE() ;clear screen
 
  p1.x=123
  p1.y=4567
 
  ValR("12.34",realx)
  ValR("5.6789",realy)
  p2.rx=realx
  p2.ry=realy
 
  PrintF("Integer point p1=(%I,%I)%E",p1.x,p1.y)
 
  Print("Real point p2=(")
  PrintR(p2.rx) Print(",")
  PrintR(p2.ry) Print(")")
RETURN