3. Introduction to Classes, Objects and Strings

Nothing can have value without being an object of utility.

—Karl Marx

Your public servants serve you right.

—Adlai E. Stevenson

Knowing how to answer one who speaks, To reply to one who sends a message.



In this chapter you’ll learn:

• How to define a class and use it to create an object.

• How to implement a class’s behaviors as member functions.

• How to implement a class’s attributes as data members.

• How to call a member function of an object to perform a task.

• The differences between data members of a class and local variables of a function.

• How to use a constructor to initialize an object’s data when the object is created.

• How to engineer a class to separate its ...

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.