In this post, we will see Record Types | PPL | Sebesta | Data Types in Programming Language | data types in ppl, data types ppl, elementary data types in programming language, ppl, sebesta, record types
7. Record Types
A record is an aggregate of heterogeneous data elements in which the individual elements are identified by names and accessed through offsets from the beginning of the structure.
Differences between Array and Record:
1. Arrays are used when all the data values have the
same type and/or are processed in the same way.
Records are used when the collection of data values is heterogeneous and the different fields are not processed in the same way.
2. Array elements are accessed using Subscripts while Record elements are accessed using Field Names.
Implementation in Different Programming Languages:
i. Records in C, C++, C#
In C, C++, and C#, records are supported with the struct data type.
Defining Linked List:
struct list *ptr;
Defining Linked List variable
struct list node;
Defining Binary Tree
struct btree *lptr;
struct btree *rptr;
Defining Binary Tree variable
struct btree node;
ii. Records in COBOL
05 FIRST PICTURE IS X(20).
05 MIDDLE PICTURE IS X(10).
05 LAST PICTURE IS X(20).
02 HOURLY-RATE PICTURE IS 99V99.
iii. Records in Ada
type Employee_Name_Type is record
First : String (1..20);
Middle : String (1..10);
Last : String (1..20);
type Employee_Record_Type is record
iv. Records in Java & C#
In Java and C#, records can be defined as data classes, with nested records defined as nested classes.
Data members of such classes serve as the record fields.
A compile-time descriptor for a record
Watch following video:
Watch on YouTube: https://www.youtube.com/watch?v=pnnpdPU1Ikg
Post a Comment