O'Reilly logo

An Introduction to Design Patterns in C++ with Qt™, Second Edition by Paul Ezust, Alan Ezust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required