7.3.1. Class Members Revisited
To explore several of these additional features, we’ll define a pair of cooperating classes named Screen
and Window_mgr
.
Defining a Type Member
A Screen
represents a window on a display. Each Screen
has a string
member that holds the Screen
’s contents, and three string::size_type
members that represent the position of the cursor, and the height and width of the screen.
In addition to defining data and function members, a class can define its own local names for types. Type names defined by a class are subject to the same access controls as any other member and may be either public
or private
:
class Screen {public: typedef std::string::size_type pos;private: pos cursor = 0; pos height = 0, width = 0; std::string ...
Get C++ Primer, Fifth 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.