previous | start | next

Example Declarations

Ex1. (a) Type is union blob
     (b) Variable u is declared to be of type union blob and so is
     (c) variable v.
     (d) blob is called the union tag

  union blob {
    int x;
    float y;
  } u;

  union blob v;

Ex2. (a) Union type with no tag used to declare variable u
     (b) No tag for union, so no name for the union type.
     (c) So whole union has to be repeated to declare variable v

  union {
    int x;
    float y;
  } u;

  union {
    int x;
    float y;
  } v;



previous | start | next