© Will Briggs 2021
W. BriggsC++20 for Lazy Programmershttps://doi.org/10.1007/978-1-4842-6306-8_15

15. Classes

Will Briggs1  
Lynchburg, VA, USA

Till now, what we’ve covered has been essentially C with a few tweaks, notably cin and cout. Now it’s time to add the thing that puts the + in C++: classes. They won’t give us new abilities like cin/cout, SSDL functions, or control structures like loops. What they will do is help us keep things organized so we don’t get confused; minimize errors; and make expressing things simpler – so we can trust the code we write and use it for bigger and better projects.

As an example, here’s a class type to store a calendar date:
class Date
    int day_;
    int month_;
    int year_;
Date appointment; // Variables ...

Get C++20 for Lazy Programmers: Quick, Easy, and Fun C++ for Beginners now with O’Reilly online learning.

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