Structures

Basics of structures

  1. Structures allow storage of muliple values of varying types under one name
  2. Declare a structure like this:
Example
struct example
{
  int x;
  double y;
};

Using structures

  1. The structure name is a label for the type of structure defined
  2. To actually use the structure, declare a variable of type structurename
  3. To reference a value, use name.value
Example
struct person
{
  int age;
  double cash;
};

person bob;

bob.age = 37;
bob.cash = 20.34;