CS201 Study Guide

Unit 3: Pointers and References in C++

3a. Interpret native C/C++ variable declarations relative to data organization and access

  1. How do bytes compose words in computer hardware?
  2. What are various native data types and the amount of memory each occupies?
  3. How can we extend the accuracy of numeric data types using extended declarations?
  4. What are the means by which C/C++ programs can report the actual memory occupied by a given native variable type and by contiguous abstract data types?

Although this is not a language course, we presented a brief review. Understanding the syntax of C/C++ is required before studying memory pointers, and knowledge of pointers is essential to working with abstract data types and data structures. C/C++ has numerous native data types. These can be combined into more complex abstract data types, along with manipulation and access methods. Each native data type and each abstract data type occupies memory, which, along with runtime, is another resource that is consumed whenever a program is running.

 

3b. Choose approaches to using pointer variables for memory access within scalars, vectors, and arrays

  1. How does one declare a pointer to a native data type or abstract data type?
  2. What is necessary to be done to obtain the address of a variable?
  3. To what does a memory pointer actually refer?
  4. By what arithmetic process can the address of cells within contiguous-memory vectors and arrays and the elements of abstract data types be obtained?
  5. Do vectors, arrays, and other abstract data types necessarily occupy contiguous memory? Explain.

Be certain that you understand memory pointers (watch this video from 35:51 until the end). These are fundamental to data structures. Review how a pointer's value is incremented and decremented and how pointers can be manipulated to obtain the value of data elements. For more detail, look into pointer arithmetic. This is a practical matter that applies to any contiguous-memory object and is also useful within objects occupying non-contiguous memory. Be sure to get plenty of practice since pointers and pointer arithmetic are usually not well understood by those just beginning their study of data structures.

 

Unit 3 Vocabulary

This vocabulary list includes terms that might help you with the review items above and some terms you should be familiar with to be successful in completing the final exam for the course.

Try to think of the reason why each term is included.

  • sizeof
  • pointer
  • address
  • extended data type
  • compound data type
  • word
  • byte
  • width
  • bit
  • initialization
  • type qualifier
  • pointer incrementing
  • pointer arithmetic
  • indirection
  • dereferencing