9. Classes: A Deeper Look; Throwing Exceptions

My object all sublime I shall achieve in time.

—W. S. Gilbert

Is it a world to hide virtues in?

—William Shakespeare

Have no friends not equal to yourself.

—Confucius

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 ...

Get C++ How to Program, Ninth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.