Skip to Content
Introduction to Design Patterns in C++ with Qt, 2nd Edition
book

Introduction to Design Patterns in C++ with Qt, 2nd Edition

by Alan Ezust, Paul Ezust
September 2011
Intermediate to advanced
768 pages
15h 18m
English
Pearson
Content preview from Introduction to Design Patterns in C++ with Qt, 2nd Edition

Chapter 4: Lists

Whenever possible, you should use lists instead of arrays. This chapter introduces containers and discusses various ways of grouping things in lists and how to iterate through them.

4.1 Introduction to Containers

There are many occasions when it is necessary to deal with collections of things. The classic approach in languages like C is to use arrays (Section 21.4) to store such collections. In C++, arrays are regarded as evil.

Following are a few good reasons to avoid using arrays in C++:

• Neither the compiler nor the runtime system checks array subscripts to make sure that they are within the correct range.

• A programmer using an array has the responsibility to write extra code to do the range checking.

• Arrays are either ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

An Introduction to Design Patterns in C++ with Qt 4

An Introduction to Design Patterns in C++ with Qt 4

Alan Ezust, Paul Ezust
Programming with Qt, 2nd Edition

Programming with Qt, 2nd Edition

Matthias Kalle Dalheimer

Publisher Resources

ISBN: 9780132851619Purchase book