Structures
A struct is a type that groups a set of related chunks of data together in memory. You use structs when you would like to group data together under a common type. For example, you will create a struct called Town in MonsterTown to model a town with a monster problem.
Making Town a struct encapsulates its data within a single type, and placing its definition in its own file provides a convenient location to find its implementation. In previous chapters, you modeled a town in a playground. Because the example was relatively small, this was not all that limiting. A playground is great for rapidly prototyping some code, but it does not really match the sort of projects that you will be working with in real app development. It ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access