Chapter 21. Understanding C++ Classes

  • 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


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 live online training, plus books, videos, and digital content from nearly 200 publishers.