csci 20 :: book learning challenge 9 (due tues, mar 29)
Submitting your work: Complete this exercise on your own.

Fill in all of the "Answer" boxes, then print the answer grid that you see after you press "Prepare for printing".

Staple all pages together and submit to the instructor on the date listed above.

Questions:

Read and answer the following (all questions refer to the class defined in Container.hpp):

Your name:
  1. Define constructor and describe what constructors do in a C++ program.
    Answer:
  2. When are constructors invoked/executed?
    Answer:
  3. What would be the name of a constructor for the class Treasure?
    Answer:
  4. Write the C++ code to implement a default constructor, inside the class definition, for the class Treasure below (the constructor will contain no executable statements):
    class Treasure {

          public:
               // constructor implementation goes here

    };
    Answer:
  5. Write the C++ code to implement a default constructor, outside the class definition, for the class Treasure below (the constructor will contain no executable statements):
    class Treasure {

          public:
               Treasure ();

    };

    // constructor implementation goes here

    Answer:
  6. Write the C++ code to declare a Treasure object named goldenDonut, using the default constructor.
    Answer:
  7. Write the C++ code to implement a parameterized constructor, inside the class definition, for the class Treasure below (the constructor will accepts as its parameter an integer named newValue, and assign this parameter to the member property value):
    class Treasure {

          private:
               int value;

          public:
               // constructor implementation goes here

    };
    Answer:
  8. Write the C++ code to implement a parameterized constructor, outside the class definition, for the class Treasure below (the constructor will accepts as its parameter an integer named newValue, and assign this parameter to the member property value):
    class Treasure {

          private:
               int value;

          public:
               Treasure ();

    };

    // constructor implementation goes here
    Answer:
  9. Write the C++ code to declare a Treasure object named silverChalice, using the parameterized constructor. Supply 999 as the value for the object.
    Answer:
  10. What is it called when you define two (2) or more constructors for a class (differentiated by their parameter lists)?
    Answer:

Total points for this book learning challenge:

150 points