In most applications, you will want to associate several data items together. For example, you may want to define a time record that has an integer for each of the following: the hour, the minute, and the second of the specified time. You can declare them like this:
// start work int start_sec = 0; int start_min = 30; int start_hour = 8; // end work int end_sec = 0 int end_min = 0; int end_hour = 17;
This approach becomes quite cumbersome and error-prone. There is no encapsulation, that is, the _min variables can be used in isolation to the other variables. Does the minutes past the hour make sense when it is used without the hour that it refers to? You can define a structure that associates these items:
struct time_of_day ...