10. Classes: A Deeper Look, Part 2

Objectives

In this chapter you'll learn:

  • To specify const (constant) objects and const member functions.

  • To create objects composed of other objects.

  • To use friend functions and friend classes.

  • To use the this pointer.

  • To create and destroy objects dynamically with operators new and delete, respectively.

  • To use static data members and member functions.

  • The concept of a container class.

  • The notion of iterator classes that walk through the elements of container classes.

  • To use proxy classes to hide implementation details from a class's clients.

But what, to serve our private ends, Forbids the cheating of our friends?

Charles Churchill

Instead of this absurd division into sexes they ought to class people as static and dynamic.

Evelyn Waugh

Have no friends not equal to yourself.

Confucius

Outline

10.1 Introduction
10.2 const (Constant) Objects and const Member Functions
10.3 Composition: Objects as Members of Classes
10.4 friend Functions and friend Classes
10.5 Using the this Pointer
10.6 Dynamic Memory Management with Operators new and delete
10.7 static Class Members
10.8 Data Abstraction and Information Hiding
  10.8.1 Example: Array Abstract Data Type
  10.8.2 Example: String Abstract Data Type
  10.8.3 Example: Queue Abstract Data Type
10.9 Container Classes and Iterators
10.10 Proxy Classes
10.11 Wrap-Up