O'Reilly logo

An Introduction to Design Patterns in C++ with Qt 4 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 10. Generics and Containers

This chapter covers more deeply the subject of generics. Generics are classes and functions that can operate just as easily on objects as primitive types. Qt container classes are generic, template-based classes, and we will see examples using lists, sets, and maps. Operators, managed containers, and resource sharing are also discussed.

10.1

Generics and Templates

214

10.2

Containers

219

10.3

Managed Containers, Composites, and Aggregates

221

10.4

Implicitly Shared Classes

224

10.5

Generics, Algorithms, and Operators

225

10.6

Serializer Pattern

227

10.7

Sorted Map Example

229

Generics and Templates

C++ supports four distinct categories of types:

  1. Primitives: int, char, float, double, etc.

  2. Pointers

  3. Instances of class/struct

  4. Arrays

Because ...

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