Objectives
In this chapter you’ll:
• Use an include guard.
• Access class members via an object’s name, a reference or a pointer.
• Use destructors to perform “termination housekeeping.”
• Learn the order of constructor and destructor calls.
• Learn about the dangers of returning a reference to private
data.
• Assign the data members of one object to those of another object.
• Create objects composed of other objects.
• Use friend
functions and friend
classes.
• Use the this
pointer in a member function to access a non-static
class member.
9.3 Class Scope and Accessing Class Members
9.4 Access Functions and Utility Functions
9.5 Time
Class Case Study: Constructors with Default Arguments
9.7 When Constructors and Destructors Are Called
9.8 Time
Class Case Study: A Subtle Trap—Returning a Reference or a Pointer to a private
Data Member
9.9 Default Memberwise Assignment
9.10 const
Objects and const
Member Functions
9.11 Composition: Objects as Members of Classes
9.12 friend
Functions and friend
Classes