KRHS Internet Lesson

Teacher Name:Mr. Rung                          Date of Lesson: January

Course Name: C++                    Lesson Name: Chap 12.2ab

Student Name

Password


Objective
To complete the wokbook exercises.


Primary Focus
Answer the questions below.

Site Links
Course Home Page

Additional Resources

Site Links


Question #1

When multiple objects are instanciated from the same class, the code required to perform the operations is not duplicated in memory.

True         False


Question #2

When quotation marks (" ") appear around a header filename in an #include statement, the header file is one of the compiler's pre-compiled library functions.

True         False


Question #3

Messages are sent to an object by using the object's name, a period, and the message.

True         False


Question #4

Because objects are simpler than other data types, a different term is used to describe the decla- ration of an object.

True         False


Question #5

The definition of an object is known as a class.

True         False


Completion #1

Suppose you have a class named Grocery -List. Write the statement to create an instance of the class.
Name the instance My-List .


Completion #2

Suppose there is a method in the class described above called Show-List. Write a statement that sends the Show-List message to the My-List object, instructing the object to display the grocery list.


Completion #3

What is one of the terms used to describe the period that appears between an object's identifier and the message?


Completion #4

What does the compiler do when it encounters a declaration like circle my-circle; assuming circle is a class?


Completion #5

Describe the relationship between a class and an object, and give an example from the real world.


Using a Class

Directions: Study the class definition below, then write a program that uses the sphere class and e-mail it to frung@krhs.net with the subject 12.2c. Your program should instanciate a sphere object, set its radius to 4.3, then print the volume of the sphere to the screen. Assume the sphere class definition is in a file named SPHERE.H.

class sphere
{
public:
   // constructors
   sphere();                                 // default constructor
   sphere(const sphere &);    // copy constructor

   // member functions
   void SetRadius(double);
    double Volume();

private:
   // data
   double radius;
} ;