Chapter 7. Classes and Objects
One of the central features of C++ is that of classes, the single most important ability that C++ adds to C. There are many ways to think of a class. One of the best ways is this: A class is a user-defined type. Once you declare it, you can use it just as you would int, char, or double.
By declaring a class, you create a fundamental new data type, extending C++ itself. You can, if you choose, define how the type responds to operators (such as +, -, or <). You can also provide services in the form of member functions, effectively creating intelligent data types. An object “knows” how to respond to function calls and retains that knowledge even when it is accessed through a pointer of a more general type. (This is ...
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