Overview
Recall that C++ data types are classified into three categories: simple, structured, and
pointers. Chapter 12 introduces students to the pointer data type. Students will learn
how to declare and manipulate pointers. They will explore how to work with dynamic
variables and arrays, and examine the issues involved with using pointers as member
variables in classes. Students will also be introduced to additional object-oriented
techniques, including virtual functions and abstract classes.
Objectives
In this chapter, the student will:
• Learn about the pointer data type and pointer variables
• Explore how to declare and manipulate pointer variables
• Learn about the address of operator and the dereferencing operator
• Learn how pointers work with classes and structs
• Discover dynamic variables
• Explore how to use the new and delete operators to manipulate dynamic variables
• Learn about pointer arithmetic
• Learn how to work with dynamic arrays
• Become familiar with the limitations of range-based for loops with dynamic arrays
• Explore how pointers work with functions as parameters and functions as return values
• Become familiar with the shallow and deep copies of data
• Discover the peculiarities of classes with pointer member variables
• Learn about virtual functions
• Become aware of abstract classes
• Examine the relationship between the address of operator and classes
Teaching Tips
Pointer Data Type and Pointer Variables
1. Define the term pointer variable and explain its purpose in C++.