CS 105: C++
Project 3 Required Concepts
C: Chapter 4, 5

  1. The keyword "static" has multiple (and sometimes unexpectedly different) uses.  Know what it means when applied to a global variable declaration, a function declaration, and the definition of a variable within a function.

  2. Understand how to define a variable in one file, and declare (and use) it in another file.

  3. Understand how to declare a function without defining it, so that it can be used before it's defined or used if it's defined in another file.
  4. Know how to declare a simple pointer (e.g., a pointer to an int), and know how to set it to point to something.

  5. Know how to dereference a pointer to read or change the value it points to.

  6. Understand the basics of argc and argv.  What are each of them set to when your program is run from the command line? What is argv[0]?  If a program takes two arguments (not counting the program name), is its argc 2, or is it something else?

  7. Although they are identical to the compiler, which of the following pointer declarations is typically used in the reading?

      int *ip;
      int* ip;

    Why is that?  Here's a hint: Which of the following declares two pointers to int?

      int *ip1, *ip2;
      int* ip1, ip2;

  8. Understand exactly how to use pointers to "work around" the fact that all functions in C are pass by value.  For example, the code below seems to be trying to add 5 to x, but it fails due to pass-by-value.  How could you change add_5 and its call from main (without making add_5 return a value) to fix this?

      void add_5(int n)
      {
        n = n + 5;
      }

      main()
      {
        int x = 2;

        add_5(x);
      }



Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.