In
this chapter, you’ve learned the fundamental “twist” of C++:
that you can place functions inside of structures. This new type of structure
is called an
abstract
data type
,
and variables you create using this structure are called
objects,
or
instances,
of that type. Calling a member function for an object is called
sending
a message
to that object. The primary action in object-oriented programming is sending
messages to objects.
Although
packaging data and functions together is a significant benefit for code
organization and makes library use easier because it prevents name clashes by
hiding the names, there’s a lot more you can do to make programming safer
in C++. In the next chapter, you’ll learn how to protect some members of a
struct
so that only you can manipulate them. This establishes a clear boundary between
what the user of the structure can change and what only the programmer may
change.