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.
—Amenemopel
Objectives
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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.