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 11: 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 on primitive types. Qt container classes are generic, template-based classes, and we show the use of lists, sets, and maps. This chapter also discusses overloaded operators, managed containers, and implicit sharing.

11.1 Generics and Templates

C++ supports four distinct categories of types:

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

• Pointers

• Instances of class/struct

• Arrays

Because there is no common base type for these four distinct type categories, writing generic functions and classes that can operate on multiple type categories would be difficult without the use ...

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