Test 1 Study Guide

The test is 100 points long. It includes multiple-choice and true-false question, short coding and longer coding.

The material on the test is more or less what we have been doing on assignments 1 through 3. Look at the asignments and look at the quiz questions.

Topics we have not encountered in the homework are not likely to appear on this test. For instance, as we have no yet made any use of reference arguments in the homework, you need not worry about references on this test. The topics listed below and the sample problems do include a few extra items.


Topics

g++ compiler

make utility and Makefiles

Header guards

Sorting

Input/Output

Program Structure

File input/output


Sample Questions

  1. Suppose we have a project which uses several source code files:
             Calc.cc includes files "Rational.h" and "BigUInt.h".
             Rational.cc includes files "BigUInt.h" and "Rational.h".
             BigUInt.cc includes files "Byte.h" and "BigUInt.h". 
             Byte.cc includes the file "Byte.h".

    Write a make file which includes targets to compile the 4 .cc files (one at a time), to link the 4 resulting .o files into an executable named "Calc", and to clean up the working directory.

  2. Name three g++ compiler options and what they do.

  3. What is the major difference between a class and a struct?

  4. Write a declaration for a constant pointer to a character.

  5. Write a declaration for a pointer to a constant character.

  6. What are header guards? Why do we need them?

  7. Suppose I have a function called DoIt with 5 arguments, A, B, C, D and E. I want 3 of the arguments to have default values: C = 13, D = 54.9, and E = 'X'. DoIt returns void.

    The other two arguments, A and B, are each integers.

    Write a prototype statement for the function.

    Write the function header for the function. (Notice this is not the same.)

    Suppose I want to use DoIt passing it the values 13 for A, 47 for B and 'Z' for E. Write the line to call the function.

    Suppose I want to use DoIt passing it the values 31 for A, 74 for C and 'S' for E. Write the line to call the function.

  8. I want to have a Date class.

    There should be 3 private data members, Day, Month and Year, all integers.

    There should be a constructor which will initialize a Date object to January 1, 2011.

    There should also be a constructor which takes 3 integer arguments and initializes the Date object using them.

    There should be public methods to change the values of Day, Month and Year, and there should be public methods to return the values of Day, Month and Year.

    There should be a PrintDate method to print the date in the format 3/1/2011.

    All methods that can be constant should be constant.

    1. Write the complete header file for the Date class.

    2. Write the code for the second constructor.

    3. Write the code for the GetMonth method.

    4. Create an object of the Date class using the default constructor.

    5. Change the Year of the object just created to 2012.

    6. Write a function (not a member of the class) to print just the day and month (as in 3/1).

  9. Suppose we have an array ALPH of 8 characters: G A P E R Z M H. We want to sort it in ascending order.

  10. What #include statements do we need if:

  11. What steps are involved in opening a file for binary input, reading from it, and closing the file?