Chapter 21. Understanding C++ Classes

<feature>
  • Discover C++ classes and class design

  • Learn to encapsulate data and functions into C++ classes

  • Understand the this pointer

  • Discover how to use constructors and destructors

  • See how to specify access to class members

</feature>

Creating C++ Classes

If there’s one thing that truly sets C++ head and shoulders above C, it’s got to be classes. C++ classes offer you an elegant, object-oriented solution to writing code that’s easy to maintain and modify. In procedural programming languages, you typically create data structures and write functions to manipulate them, but in C++, you can bind the functions to the data that the functions act on. The class is the cornerstone of object-oriented programming in C++. ...

Get Practical C++ 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.