Chapter 11 Reading Assignment

Chapter 11 is appropriately titled "More About Classes". It is a potpourri with lots of little details about how you can craft classes in C++. The work in this chapter is (alas) very detailed.


Section 11.1 - Static members

How is a static member variable different than a regular (non-static) member variable?

What are the restrictions on what a static member function can do?

On paper, write the C++ code for a class, Example. Design the contents of "Example.h", the interface header, and "Example.cpp", the implementation file. The Example class has:

Section 11.2 - Friends

What is the purpose of making a function a friend of a class?

Section 11.3 - Member-wise copy

Using the class Example above, jot down a code fragment where member-wise assignment would take place.

Section 11.4 - Copy constructors

When is the copy constructor for a class called?

What is a default copy constructor? What does it do? In what situations do default copy constructors fail to work properly?

For class Example, what is the function prototype of a copy constructor?

Why are constant reference parameters (look in your index) commonly used in copy constructors?

Section 11.5 - Operator overloading

Write the function prototypes to overload the following operators for your Example class:

Section 11.6 - Object conversion

Write the function prototype for converting the Example class to an int value.

Section 11.7 - Object composition

What is object composition? What relationship between classes does it model?