Chapter 2: Top of the class

This chapter provides an introduction to classes and objects and how member functions operate on objects. Classes and objects can be arranged in different structures, and this chapter presents some ways to describe the relationships between them. UML is introduced. static and const members are explained. Constructors, destructors, copy operations, and friends are discussed.

2.1 First, There Was struct

In the C language, the struct keyword enables the programmer to define a structured chunk of memory that can store a heterogeneous set of data. Example 2.1 shows the definition of a structured piece of memory composed of smaller chunks of memory.

Example 2.1 src/structdemo/demostruct.h

[ . . . . ]struct Fraction {    int ...

Get Introduction to Design Patterns in C++ with Qt, 2nd 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.