The points on the final will be distributed approximately as follows:

  Material from midterm 1: 45 points
  Material from midterm 2: 45 points
  Material after midterm 2: 60 points

To get samples of questions for the material from midterms 1 or 2 look at
the links "Sample Exam 1 Questions" or "Sample Exam 2 Questions".


Below are examples of questions from the material following midterm 2:

What does it mean to CHAIN insertion or extraction operators? (5)

Explain the effect of each of the following commands.  Include an example
demonstrating your answer. (5 each)

  cout.setf(ios::hex,ios::basefield)
  cout.width(5)
  cout.fill('_')
  cout.setf(ios::internal,ios::adjustfield)
  cout.setf(ios::fixed,ios::floatfield)
  cout.precision(3)
  cin.eof()
  ifstream obj("file.dat")
  obj.close()


Translate the following C code to C++ (you cannot use stdio.h) (15)

  #include 

  void main() {
    char firstname[16];
    char lastname[16];
    float startbal;
    float prev;
    float curr;
    int numyears;
    float interest;
    int y;

    printf("Please enter name (last first): ");
    scanf(" %15s %15s",lastname,firstname);
    printf("\nHi %c%c!!\n\n",firstname[0],lastname[0]);
    printf("What is your starting balance: ");
    scanf("%f",&startbal);
    printf("How many years do you plan to wait: ");
    scanf("%d",&numyears);
    printf("What interest do you expect: ");
    scanf("%f",&interest);
    printf("\n\nUnder these assumptions your money would grow as follows\n");
    printf("Year  Balance  Increase\n");
    printf("  0   $%6.2f      none\n",startbal,0.0);
    curr = startbal;
    for (y = 1; y <= numyears; y++) {
      prev = curr;
      curr *= (1 + interest);
      printf("%3d   $%6.2f   $%6.2f\n",y,curr,(curr - prev));
    }
  }

A swap command for integers in C would be written as follows:

  void swap(int *x, int *y) {
    var temp;

    temp = *x;
    *x = *y;
    *y = temp;
  }

  to have it swap the two integers A and B you would use the call:

    swap(&A,&B);

  How could you write this routine in C++ using true reference parameters
  (and how would you call it to swap A and B)? (10)

How many arguments does the following function require?  What is the
  maximum number of arguments it can take?  Give an example demonstrating
  each case and show the output for your examples. (10)

  void func(int A, char B = '\n', float C = 3.1415) {
    cout << A << B << C << endl;
  }

How do you dynamically allocate a 1-dimensional array of integers in C++? (5)

Give code to dynamically allocate a 2-dimensional array of floating point
  values with 8 rows and 5 columns in C++.  (10)

What is the difference between a class declared using the keyword class and
  one declared using the keyword struct in C++? (5)

How do you implicitly request that a method be made inline in C++?  How do
  you explicitly request that a method be made inline?  Give examples of
  each.  (10)

What is the difference between the private and public access modifiers in
  a class in C++? (5)

Give an example of a class that has both an accessor and mutator function.  (5)

Rich has declared a class Name as follows:

  class Name {
    public:
      Name(char *first, char *last) {
	// Your code here
      }
      ~Name() {
	// Your code here
      }
      Name(const Name& obj) {
	// Your code here
      }
    private:
      Name() {}
      char *firstname;
      char *lastname;
  };

  Rich wants to complete the code but is not sure how.  He wants the
  constructor for the class to take two strings, first and last, and allocate
  enough space to hold these strings in the instance variables firstname and 
  lastname, then copy the string (first to firstname and last to lastname)
  to these variables.  Help him out and complete the constructor. (10)

  He also wants the destructor and copy constructor to do appropriate things
  given that space is being dynamically allocated on the stack.  Write
  the code for these methods. (10)

  The code prevents other programmers from using the default constructor.
  Explain how it does this. (5)

  Add a method Greeting to the class Name which prints out a message:

    Hi FL!!

  where F is the first character of the Name instance's firstname string and
  L is the first character of the Name instance's lastname string. 
  Assuming you had an instance employee1 of class Name, how would you
  call the method Greeting on this instance? (10)