Welcome to Beginning C++17. This is a revised and updated version of Ivor Horton’s original book called Beginning ANSI C++.
The C++ language has been extended and improved considerably since then, so much so that it was no longer possible to squeeze detailed explanations of all of C++ into a single book.
This tutorial will teach the essentials of the C++ language and Standard Library features, which will be more than enough for you to write your own C++ applications.
With the knowledge from this book, you should have no difficulty in extending the depth and scope of your C++ expertise. We have assumed no prior programming knowledge. If you are keen to learn and have an aptitude for thinking logically, getting a grip on C++ will be easier than you might imagine. By developing C++ skills, you’ll be learning a language that is already used by millions and that provides the capability for application development in just about any context. C++ is very powerful.
Arguably, it’s more powerful than most programming languages. So, yes, like with any powerful tool you can wield some considerable damage if you use it without proper training. We often compare C++ to a Swiss Army knife: age-old, trusted, incredibly versatile, yet potentially mind-boggling and full of pointy things that could really hurt you. Once someone clearly explains to you what all the different tools are meant for, however, and teaches you some elementary knife safety rules, then you’ll never have to look for another pocketknife again. C++ does not need to be dangerous or difficult at all either.
C++ today is much more accessible than many people assume. The language has come a long way since its conception nearly 40 years ago. In essence, we have learned how to wield all its mighty blades and tools in the safest and most effective way possible.
And, more importantly perhaps, the C++ language and its Standard Library have evolved accordingly to facilitate this. The past decade in particular has seen the rise of what is now known as “modern C++.” Modern C++ emphasizes the use of newer, more expressive, safer language features, combined with tried and tested best practices and coding guidelines. Once you know and apply a handful of simple rules and techniques, C++ loses much of its complexity. Key is that someone properly and gradually explains not simply what you can do with C++ but rather what you should do with C++. And that’s where this book comes in! In this latest revision of the book, we have gone through great lengths to bring it back in line with the new, modern era of C++ programming we’re living in.
As before, we of course do so in the form of a gradual, informal tutorial. We’ll introduce to you all the shiny blades and pointy things C++ has to offer—both old and new—using many hands-on coding samples and exercises. But that’s not all: more than ever before we’ve made sure to always explain which tool is best to use for which purpose, why that is the case, and how to avoid getting cut.
We’ve made sure that you will begin C++, from day one, using the safe, productive, modern programming style that employers will expect from you tomorrow. The C++ language in this book corresponds to the latest International Organization for Standardization (ISO) standard, commonly referred to as C++17.
Not everything of C++17 is covered, since many of the extensions compared to previous versions of the language are targeted toward more advanced use. All the examples in the book can be compiled and executed using C++17-conforming compilers that are available now.