Skip to content

Lesson 79: Records

Fields that belong together

  • A record is a composite data type: one item made of several fields, which can have different data types.
  • In C++ you define a record type with struct. Then you can make variables and arrays of that type.
  • You reach a field with a dot: team[1].name.
Pseudocode (9618) C++
TYPE Player struct Player {
DECLARE Name : STRING String name;
DECLARE Score : INTEGER int score;
ENDTYPE };
  • An array of records replaces parallel arrays (Robots lesson 48): the name and the score can never get out of step.

Log in or create account

IGCSE, A-Level & AP