CHAP15 - Chapter 15 Pointers, Dynamic Data, and Reference...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 15 Pointers, Dynamic Data, and Reference Types Chapter 15 POINTERS, DYNAMIC DATA, AND REFERENCE TYPES CHAPTER GOALS To be able to declare variables of pointer types. To be able to take the addresses of variables and to access the variables through pointers. To be able to write an expression that selects a member of a class, struct , or union that is pointed to by a pointer. To be able to create and access dynamic data. To be able to destroy dynamic data. To be able to declare and initialize variables of reference types. To be able to access variables that are referenced by reference variables. To understand the difference between deep and shallow copy operations. To understand how C++ defines the term initialization . To be able to identify the four member functions needed by a C++ class that manipulates dynamic data. To be able to use pointers to improve program efficiency. CHAPTER OUTLINE I. Pointers A. Pointer Variables B. Pointer Expressions II. Dynamic Data III. Reference Types IV. Classes and Dynamic Data A. Class Destructors B. Shallow Versus Deep Copying C. Class Copy-Constructors V. Problem-Solving Case Study : Personnel Records VI. Problem-Solving Case Study : Dynamic Arrays VII. Testing and Debugging A. Testing and Debugging Hints VIII. Summary GENERAL DISCUSSION Chapter 15 encompasses three major topic areas: pointers, dynamic allocation of data, and C++ class operations related to dynamic data. Each of these topics has several new concepts associated with it. The first section of the chapter introduces fundamental pointer concepts pointer variables, address-taking, direct versus indirect addressing, the null pointer, and operations on pointers. Students do not have much trouble with the basic idea of taking the address of something (using ), storing this address into a pointer variable, and then dereferencing the pointer (using * ). The material quickly becomes more complicated with discussions of pointers to arrays, pointers to struct s and class objects, and copying pointers rather than the objects they point to. We address some of the more difficult issues in the Hard Parts section. 52
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Chapter 15 Pointers, Dynamic Data, and Reference Types This chapter gives only limited attention to the topic of pointer arithmetic. Many C and C++ texts describe in depth the correspondence between pointers and arrays. It is our opinion that this topic, while useful in upper-division course work, is a distraction in a first-year course. Using pointer variables rather than indices to step through arrays is purely an optimization strategy, springing from C's origin as a system programming language. At this stage, we believe it is important for students to know only three things: 1. In a C++ expression, an array name (without index brackets) has a value: the base address of the array. 2.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 20

CHAP15 - Chapter 15 Pointers, Dynamic Data, and Reference...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online