Chapter 9. Custom Classes

Images

Objectives

In this chapter, you’ll:

Define a custom class and use it to create objects.

Implement a class’s behaviors as member functions and attributes as data members.

Access and manipulate private data members through public get and set functions to enforce data encapsulation.

Use a constructor to initialize an object’s data.

Separate a class’s interface from its implementation for reuse.

Access class members via the dot (.) and arrow (->) operators.

Use destructors to perform “termination housekeeping.”

Learn why returning a reference or a pointer to private data is dangerous.

Assign the data members ...

Get C++20 for Programmers, 3rd 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.