Treating Similar Classes
Our programs model a variety of real-life objects through their data (object state) and operations (object behavior). This is a mantra of object-oriented design, but it is up to each designer to decide what to include in each class. The modeling of real-life entities should ideally reflect "common features" among real objects, for example, among inventory items, event counters, or bank accounts.
These "common features" are of course in the eye of the beholder, and C++ has different mechanisms for representing different degrees of similarity among entities.
The first mechanism that C++ offers for capturing the common features among real-life objects is the class construct itself. We use the class construct to capture ...
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