Chapter 12. Classes

CONTENTS

Section 12.1 Class Definitions and Declarations 430

Section 12.2 The Implicit this Pointer 440

Section 12.3 Class Scope 444

Section 12.4 Constructors 451

Section 12.5 Friends 465

Section 12.6 static Class Members 467

Chapter Summary 473

Defined Terms 473

In C++ we use classes to define our own abstract data types. By defining types that mirror concepts in the problems we are trying to solve, we can make our programs easier to write, debug, and modify.

This chapter continues the coverage of classes begun in Chapters 2 and 5. We’ll cover in more detail the importance of data abstraction, which lets us hide the internal representation of an object while still allowing public operations to be performed on the object. ...

Get C++ Primer, Fourth 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.