In this book we sometimes will use certain code in the examples before having explained it in detail. This chapter is intended to help you when this occurs by giving presenting an overview of the major elements of C++ and how they hang together. Well also explain a few concepts relating to the representation of numbers and characters in your computer.
Modern C++
The C++ programming language was originally developed in the early 1980s by Danish computer scientist Bjarne Stroustrup. That makes C++ one of the older programming languages still in active usevery old, in fact, in the fast-paced world of computer programming. Despite its age, though, C++ is still standing strong, steadily maintaining its top-five position in most popularity rankings for programming languages. Theres no doubt whatsoever that C++ still is one of the most widely used and most powerful programming language in the world today.
Just about any kind of program can be written in C++, from device drivers to operating systems and from payroll and administrative programs to games. Major operating systems, browsers, office suites, email clients, multimedia players, database systemsname one and chances are its written at least partly in C++. Above all else, C++ is perhaps best suited for applications where performance matters, such as applications that have to process large amounts of data, modern games with high-end graphics, or apps that target embedded or mobile devices. Programs written in C++ are still easily many times faster than those written in other popular languages. Also, C++ is far more effective than most other languages for developing applications across an enormous range of computing devices and environments, including for personal computers, workstations, mainframe computers, tablets, and mobile phones.
The C++ programming language may be old, but its still very much alive and kicking. Or, better yet: its again very much alive and kicking. After its initial development and standardization in the 1980s, C++ evolved slowlyuntil 2011, that is, when the International Organization for Standardization (ISO) released a new version of the standard that formally defines the C++ programming language. This edition of the standard, commonly referred to as C++11 , revived C++ and catapulted the somewhat dated language right back into the 21st century. It modernized the language and the way we use it so profoundly that you could almost call C++11 a completely new language.
Programming using the features of C++11 and beyond is referred to as modern C++ . In this book, well show you that modern C++ is about more than simply embracing the languages new featureslambda expressions, auto type deduction, and range-based for loops, to name a few. More than anything else, modern C++ is about modern ways of programming, the consensus of what constitutes good programming style. Its about applying an implicit set of guidelines and best practices, all designed to make C++ programming easier, less error-prone, and more productive. A modern, safe C++ programming style replaces traditional low-level language constructs with the use of containers (Chapters ), and so on. Of course, all this probably means little to nothing to you yet. But not to worry: in this book, well gradually introduce everything you need to know to program in C++ today!
The C++11 standard appears to have revived the C++ community, which has been actively working hard on extending and further improving the language ever since. Every three years, a new version of the standard is published. In 2014, the C++14 standard was finalized, and in 2017 the C++17 edition. This book relates to C++ as defined by C++17. All code should work on any compiler that complies with the C++17 edition of the standard. The good news is that most major compilers have been keeping up with the latest developments, so if your compiler does not support a particular feature yet, it soon will.
Standard Libraries
If you had to create everything from scratch every time you wrote a program, it would be tedious indeed. The same functionality is required in many programsreading data from the keyboard, calculating a square root, and sorting data records into a particular sequence are examples. C++ comes with a large amount of prewritten code that provides facilities such as these so you dont have to write the code yourself. All this standard code is defined in the Standard Library .
The Standard Library is a huge collection of routines and definitions that provide functionality that is required by many programs. Examples are numerical calculations, string processing, sorting and searching, organizing and managing data, and input and output. Well introduce major Standard Library functionalities in virtually every chapter and will later zoom in a bit more specifically on some key data structures and algorithms in Chapter . Nevertheless, the Standard Library is so vast that we will only scratch the surface of what is available in this book. It really needs several books to fully elaborate all the capabilities it provides. Beginning STL (Apress, 2015) is a companion book that is a tutorial on using the Standard Template Library, which is the subset of the C++ Standard Library for managing and processing data in various ways. For a compact yet complete overview of everything the modern Standard Library has to offer, we also recommend the book C++ Standard Library Quick Reference (Apress, 2016).
Given the scope of the language and the extent of the library, its not unusual for a beginner to find C++ somewhat daunting. It is too extensive to learn in its entirety from a single book. However, you dont need to learn all of C++ to be able to write substantial programs. You can approach the language step-by-step, in which case it really isnt difficult. An analogy might be learning to drive a car. You can certainly become a competent and safe driver without necessarily having the expertise, knowledge, and experience to drive in the Indianapolis 500. With this book you can learn everything you need to program effectively in C++. By the time you reach the end, youll be confidently writing your own applications. Youll also be well equipped to explore the full extent of C++ and its Standard Library.