The Class as a Mini-Program

In previous lessons, you have seen almost everything you need for an easy understanding of class types. You have learned to define and use functions for processing and to define and use structs to contain data. Now you will learn about classes, which are structs with member functions as well as member variables, and which can both contain and process data.

A variable of a class type is usually referred to as an object.

Just as a program's or function's internal state is based on the content of its variables, an object's internal state is based on the content of its member variables. The content of member variables can change as control flows through the member functions of an object, and the object will retain those ...

Get SAMS Teach Yourself C++ in 10 Minutes SECOND 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.