C++ Chapter 9: Pointers

The flashcards below were created by user senator77 on FreezingBlue Flashcards.

  1. A pointer is a construct that gives you more control of the computer's memory.
  2. A pointer is the memory address of a variable.
  3. An address that is used to name a variable is called a pointer because the address can be thought of as "pointing" to the variable.
  4. The address "points" to the variable because it identifies the variable by telling where the variable is, rather than telling what the variable's name is.
  5. Each pointer variable requires a different pointer type (i.e. a double can't point to an int).
  6. The operator new can be used to create variables that have no identifiers to serve as their names.
  7. The new operator produces a new, nameless variable and returns a pointer that points to this new variable.
  8. Variables that are created using the new operator are called dynamic variables because they are created and destroyed while the program is running.
  9. A special are of memory, called the freestore, is reserved for dynamic variables.
  10. The delete operator eliminates a dynamic variable and returns the memory that the dynamic variable occupied to the freestore so that the memory can be reused.
  11. Undefined pointer variables are called dangling pointers.
  12. Variables created with the new operator are called dynamic variables, because they are created and destroyed while the program is running.
  13. Ordinary variables are not called static variables.
  14. The ordinary variables that we have been using are called automatic variables because their dynamic properties are controlled automatically for; they are automatically created when the function in which they are declared is called and automatically destroyed when the function call ends.
  15. Global variables are variables that are declared outside of any function definition (including being outside of main).
  16. You can use typedef to define an alias for any type name or definition.
    typedef double Kilometers;
    Kilometers distance;
  17. There are 2 advantages in using defined pointer type names.
    1. It avoids the mistake of omitting an asterisk.
    2. It is seen when you define a function with a call-by-reference parameter for a pointer variable.
  18. A pointer is a memory address, so a pointer provides a way to indirectly name a variable by naming the addresss of the variable in the computer's memory.
  19. Dynamic variables are variables that are created (and destroyed) while a program is running.
  20. Memory for dynamic variables is in a special portion of the computer's memory called the freestore.
  21. When a program is finished with a dynamic variable, the memory used by the dynamic variable can be returned to the freestore for reuse; this is done with a delete statement.
Card Set:
C++ Chapter 9: Pointers
2012-02-18 18:05:52
pointer variables memory management dangling pointers

C++ Chapter 9: Pointers
Show Answers: