C++ Review for Test 2: List of Concepts Covered

Composition Relationship


Enumerations:


Arrays

Array Properties

Declaring Arrays

Initializing Arrays

Initializing Arrays of Objects

Using Arrays

Using strings

Card game example and Array Techniques


Pointers

Basics

Initializing pointers

If p is a pointer, then how can we fill in the blank?
 p = _____
Essentially, four ways:
  1. NULL pointer
  2. Another pointer of the same type
  3. The "address of" an existing variable
  4. a new operation (Dynamic Allocation -- See below)

Pointer Arithmetic:

Pointers and Arrays:

Pass by Address:

Pointers, Strings, I/O:

<cstring> library functions:


Dynamic Memory Allocation

Memory Allocation Categories

Dynamic Allocation, Deallocation

Notation:

Dynamically resizing an array (application example):

  1. dynamically create a new array of the needed size (need another pointer for this)
  2. copy the data from the old array to the new one (use a for-loop)
  3. delete the old dynamic array (keyword delete)
  4. change the pointer so that the new array has the right name

Phonebook database example - examples of dynamic allocation, dynamic resizing of array, pass by address, destructor
 


Some practice array algorithms to try (coding practice)

(You should be able to do these and other similar array algorithms)