June 2025
Intermediate to advanced
1093 pages
33h 24m
English
The print function in Listing 12.1 requires a Person to work; it is in fact specifically designed for Person and nothing else. It might even be the case that the Person type only really makes sense if you also provide a suitable set of functions that work with your new type.
These functions, along with the data in struct Person, belong to the interface of this type. It is a pity that print is not already listed in the Person type—but you can do exactly this. Combine the functions of a type with the data to form an entity such that neither can exist without the other. Such a function always requires a variable, and a variable without the associated functions is almost useless.[ 16 ] A variable that is part ...
Read now
Unlock full access