Additional Details about Structures

We should mention that you have some flexibility in defining a structure. First, you can declare a variable to be of a particular structure type at the same time that the structure is defined. You do this simply by including the variable names before the terminating semicolon of the structure definition. For example, the following statement defines the structure date and also declares the variables todaysDate and purchaseDate to be of this type:

struct date{    int month;    int day;    int year;} todaysDate, purchaseDate;

You can also assign initial values to the variables in the normal fashion. Therefore, the following defines the structure date and the variable todaysDate with ...

Get Programming in Objective-C, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.