Chapter 20. Advanced Pointers

I l @ ve RuBoard

A race that binds Its body in chains and calls them Liberty, And calls each fresh link progress.

”Robert Buchanan

One of the more useful and complex features of C++ is its use of pointers. With pointers you can create complex data structures such as linked lists and trees. Figure 20-1 illustrates some of these data structures.

Figure 20-1. Examples of pointer use
figs/c++2_2001.gif

Up to now all your data structures have been allocated by the compiler as either permanent or temporary variables . With pointers you can create and allocate dynamic data structures, which can grow or shrink as needed. In this chapter you will learn how to use some of the more common dynamic data structures.

It should be noted that C++ has something called the Standard Template Library (STL), which implements the data structures presented in this chapter. These STL classes are much more reliable and flexible when it comes to managing dynamic memory. Thus, in practice, people rarely explicitly use the data structures described below.

We will study them anyway, however, because by examining them we'll learn a lot about the basics of dynamic memory management. The linked list and tree are classic dynamic memory management tools and understanding them will give you the skills to create more complex, real world, data structures.

I l @ ve RuBoard


Practical C++ Programming
Practical C Programming, 3rd Edition
ISBN: 1565923065
EAN: 2147483647
Year: 2003
Pages: 364

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net