Chapter 11.  Generics and Containers

Table of Contents

11.1. Generics and Templates
11.1.1. Function Templates
11.1.1.1. Exercises: Function Templates
11.1.2. Class Templates
11.1.3. Exercises: Generics and Templates
11.2. Generics, Algorithms, and Operators
11.2.1. Exercises: Generics, Algorithms, and Operators
11.3. Sorted Map Example
11.4. Function Pointers and Functors
11.5. Flyweight Pattern: Implicitly Shared Classes
11.6. Exercise: Generics
11.7. Review Questions

[ fromfile: generics.xml id: generics ]

Abstract

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.