CSCI 230,

Fall 2006,

Test 2.


  1. [10 points] Give the definition for an abstract data type (ATD).
  2. [4 points] What is a C++ class, and how is it related to an ADT?
  3. [2 points] Give the syntax for a C++ class.
  4. [2 points] What is a class member?
  5. [6 points] Describe three basic operations associated with classes. Name each.
  6. What is an instance of a class?
  7. [10 points] Create a C++ class to emulate a light switch. Your class should contain a single data item, the status of the switch (on or off) and should support the following operations:
  8. [9 points] Write a routine that given an array of light switch objects, as well as the size of the array, will compute and return the number of light switches that are turned on.
  9. [2 points] What does overloading mean?
  10. [4 points] Show how to overload the == operator for your light switch class above.
  11. [2 points] What is a friend function?
  12. [2 points] Write a stream insertion operator for your light switch class. Output either the word "Off" or "On".
  13. [6 points] Give a brief description of the function of each of the following items. Make sure you discuss the input and output of each item.
    1. Preprocessor
    2. Compiler
    3. Linker
  14. [12 points] Describe what is contained in each of the following types of files. Describe who or what produces the file and how the file is commonly used
    1. Specification File
    2. Implementation File
    3. Intermediate Source Code
    4. Object File
    5. Library
    6. Executable
  15. [2 points] Draw a diagram that represents the compilation process. Include all of the terms from the previous two questions.
  16. [2 points] A specification file contains the following code. Describe what the code does and why it is present.
    #ifndef SOME_IDENTIFIER
    #define SOME_IDENTIFIER 1
    
    C++ definitions go here 
    #endif