Classes and Members

You make a new type by declaring a class. A class is a collection of variables—often of different types—combined with a set of related functions.

One way to think about a car is as a collection of wheels, doors, seats, windows, and so forth. Another way is to think about what a car can do: It can move, speed up, slow down, stop, park, and so on.

Encapsulation is bundling together all the information, capabilities, and responsibilities of an entity into a single object.

Encapsulating everything you know about a car into one class ...

Get Sams Teach Yourself C++ in 24 Hours, Third 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.