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 (also known as reserved words) that are reserved for particular uses and we cannot use them for our own variables, constants, function names (and other programming entities that we'll describe later). Any C++ book should have a list of these keywords — Appendix B of Programming in C++ for Engineering and Science, in particular. You may be surprised by what identifiers are not on that list — for example, 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.

Suggestion: Start by identifying all of the keywords.


Back to the Lab Exercise


Report errors to Larry Nyhoff (nyhl@cs.calvin.edu)