Lab 8: Experiment 12

Keywords, Locals, and Non-Locals

Issue: Which of the names in params.cpp are keywords, which are autos, and which are externs?

In Lab #2 we looked at the rules for creating identifiers, and there we noted that C++ has key words (a.k.a. reserved words) which are used for particular uses and we cannot use them for our own variables. Any C++ book should have a list of these keywords (Appendix B of C++ An Introduction to Computing). You may be surprised by what identifiers are not on that list (like cin and cout).

Exercise:

  1. Print a hard copy of your most recent version of params.cpp.
  2. Review our rules of scope.
  3. Find a list of C++ keywords.
  4. And then on your hard copy of the program:
    1. Underline each keyword.
    2. Draw a circle around each local variable (including parameters).
    3. Draw a box around each non-local variable.

Hint: you cannot do this exercise without a list of keywords, and you should start by identifying all of the keywords first.

Terminology

keyword, reserved word
Back to the Lab Exercise
© 2003 by Prentice Hall. All rights reserved.
Report all errors to Jeremy D. Frens.