
C++ For Dummies
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
An accessible walkthrough of one of the world's most popular programming languages: C++
C++ For Dummies is your from-scratch guide that explains the essentials of what you need to know to understand the language and build your very first program in C++. Bradley Jones, experienced programmer and coding educator, packs this edition with examples and clear demonstrations that explain the "why" and the "how" of programming in C++, as well as the programming concepts that will form the foundation of your code, including classes, loops, classes, objects, inheritance, and more.
C++ For Dummies provides easy-to-understand tutorials for the use of C++26 and explains the modern approach to printing and displaying information with the std::print method. It also discusses:
- Explanations of features that make C++26 better including modules, smart pointers, concepts, and ranges
- Walkthroughs of updated libraries for the filesystem, ranges, formatting, time, printing, and more
- Testing and debugging techniques
Great for programmers, developers, students, or anyone interested in learning to code in C++ who are looking for a straightforward, hands-on approach to the language, C++ For Dummies is an accessible introduction to C++26 that offers readers a reliable head-start to a fun and rewarding skillset.
More details
Other editions
Additional editions

Person
Bradley L. Jones is the owner of Lots of Software, LLC, and a Microsoft MVP in C++. He has authored numerous books on C, C++, C#, and web development, and is a bestselling technical author and international technology speaker.
Content
Introduction 1
Part 1: Getting Started with C++ Programming 7
Chapter 1: Writing Your First C++ Program 9
Chapter 2: Storing Stuff in Variables 33
Chapter 3: Doing the Math 51
Chapter 4: Show Me the Good Stuff! 59
Chapter 5: Performing Logical Operations. 71
Chapter 6: Controlling the Flow 83
Part 2: Becoming a Functional C++ Programmer 101
Chapter 7: Creating Functions 103
Chapter 8: Grouping Similar Things Together Using Arrays 123
Chapter 9: Taking a First Look at C++ Pointers 149
Chapter 10: Taking a Second Look at C++ Pointers 167
Chapter 11: Using the C++ Preprocessor 183
Part 3: Giving Your Program a Bit of Class 207
Chapter 12: Examining Object-Oriented Programming 209
Chapter 13: Adding Class to C++ 215
Chapter 14: Separating Letters from Words: Character Arrays versus Strings 235
Chapter 15: Pointing and Staring at Objects 251
Chapter 16: Protecting Members: Do Not Disturb 275
Chapter 17: "Why Do You Build Me Up, Just to Tear Me Down, Baby?" 287
Chapter 18: Making Constructive Arguments 301
Chapter 19: Making Copies with the Copy/Move Constructor 327
Chapter 20: Adding Static Members: Can Fabric Softener Help? 345
Part 4: A First Look at Inheritance 359
Chapter 21: Passing the DNA: Sharing Code with Inheritance 361
Chapter 22: Creating Virtual Member Functions: Are They for Real? 371
Chapter 23: Factoring Classes 383
Part 5: Object-Oriented Programming in Overdrive. 395
Chapter 24: Adopting a New Assignment Operator, Should You Decide to Accept It 397
Chapter 25: Playing with the Computer's File System 413
Chapter 26: Twice the Fun: Tapping into Multiple Inheritance 421
Chapter 27: Getting Ahead of Problems: Exception Handling, Contracts, and More 435
Part 6: The Part of Tens 455
Chapter 28: Ten Ways to Avoid Adding Bugs to Your Program 457
Chapter 29: Ten Ways to Make Your Programs Easier to Update and Understand 465
Index 473
Introduction
Welcome to C++ For Dummies, 8th Edition. Think of this book as C++, TL;DR Edition (or the Reader's Digest edition), bringing you everything you need to know to start programming without all the boring stuff.
What is C++? C++ is a versatile object-oriented, low-level standardized programming language. As a low-level language similar to and compatible with its predecessor, C, C++ can generate programs that are efficient and fast. It's often used to write games, graphics software, hardware control software, and other applications where performance counts.
As an object-oriented language, C++ has the power and extensibility to be used to write large-scale programs. C++ is one of the most popular programming languages for all types of programs. Most of the programs you use on your PC every day are written in C++ (or the subset, which is the C language).
C++ has been certified as a 99.9 percent pure standard, which makes it a portable language. A standard C++ compiler exists for every major operating system. Some versions support extensions to the basic language; however, it is better to learn the standard C++ first. Learning the extensions is easy after you master the basics demonstrated here.
About This Book
C++ For Dummies is an introduction to the C++ language. I start from the beginning (where else?) and work my way from early concepts through more sophisticated techniques. I assume that you have no prior knowledge (at least, not of programming).
The book is full of examples. Every concept is documented in numerous snippets and a vast number of complete programs.
C++ For Dummies considers the Why just as important as the How. The features of C++ are like pieces of a jigsaw puzzle: Rather than just present the features, I believe it's important that you understand how they fit together. You can also use this book as a reference: If you want to understand what's going on with all the multiple inheritance info, for example, just flip to Chapter 26. Each chapter contains necessary references to other, earlier chapters in case you don't read the chapters in sequence.
One superpower of C++ is that it can be used on a variety of platforms. C++ For Dummies isn't specific to a single operating system. It's just as useful if you're programming on a system for Macintosh, Linux, or Windows. This book doesn't cover Windows or .NET programming; rather, it focuses on the standard C++ programming language.
What you learn will work on any of the platforms! They key is that you need to first master a powerful programming language, like C++, even if your plan is to become an accomplished Windows application, .NET, mobile, or other type of programmer. Once you've finished C++ For Dummies, you will be in position to continue in your area of specialization, whatever it might be.
Conventions Used in this Book
As you work your way through this book, I use conventions to make it as easy for you as possible. For example, the code listings within this book appear this way:
// some program
int main()
{
.
}
When I describe a message that you see onscreen, it appears like this:
Hi mom!
If you're entering these programs by hand, you must enter the text exactly as shown, with one exception: The amount of white space (spaces, tabs, and newlines) is not critical. You can't put a space in the middle of a keyword, but you don't have to worry about entering one too many or too few spaces.
Case is critical. If you see int, it does not mean Int or INT. In C++, the words Same, same, SAME, and SaMe are four different words because the case of the letters is different. You can say that when it comes to C++, they are all not the same!
C++ words are usually based on English words with similar meanings. This can make reading a sentence containing both English and C++ difficult without a little assistance. To help, C++ commands, function names, and program names appear in a different font, like this. In addition, function names are always followed by open and closed parentheses, such as myFavoriteFunction(). The arguments to the function are left off except when there's a specific need to make them easier to read.
If you're unsure what things such as functions and arguments are, don't worry: You learn about these within this book. In this introduction, the goal is for you to learn about the conventions you come across as you read the rest of the book.
Sometimes, you're told to use menu commands, such as File ? Open. This notation means to use the keyboard or mouse to open the File menu and then choose the Open option.
As you work through this book, new features are introduced with the following three questions in mind:
- What is this new feature?
- Why was it introduced into the language?
- How does it work?
Small pieces of code are sprinkled liberally throughout the chapters. Each demonstrates some newly introduced feature or highlights some brilliant point I'm making. These snippets may not be complete and certainly don't do anything meaningful. However, every concept is demonstrated in at least one functional program you can execute and play with on your own computer.
A real-world program can take up lots of pages. However, seeing such a program is an important didactic (instructive) tool for any reader. As such, throughout this book, a series of programs has been included along with an explanation of how they work. Although these programs require longer listings, I highly recommend that you enter them in their entirety and run the code. When you do this, you'll likely type something wrong; however, that's a big part of the learning process. In this new edition, more complete listings have been included to give you more opportunities to play with code that can be entered and run.
Be Aware: This Is a Modern C++ Book
C++ has been around for many decades. Over that time, C++ has evolved into a much more modern and safer language.
To be clear, this edition of C++ For Dummies is about the current version of C++. This book teaches you about the modern application of C++, including the use of features that have been added in C++23 and C++26. Some of the changes in the newest iterations of C++ include basic topics such as how information is displayed to the screen, how you access your computer's file system, or even how you can make your programs less likely to crash.
Some older ways of coding C++ should no longer be used. I mention many of the older strategies so that you can work with older C++ programs as well. Just know, however, that the features of C++26 make it easier to write C++ programs as well as make for cleaner, more modern code that helps reduce the chances of adding errors to your code.
Icons Used in This Book
Tips highlight points that can save you lots of time and effort.
Remember this. It's important.
Remember this, too. Issues can sneak up on you when you least expect them and generate one of those truly hard-to-find bugs. These warnings will help you be prepared so you don't get surprised!
The Technical Stuff icon highlights discussions of advanced concepts and considerations. While you could skip the technical stuff entirely, it really is good stuff to know as you get more experienced with C++.
This icon flags some 2023 additions to the language compared to previous versions of the C++ standard. If you already have some familiarity with C++ and something seems completely new, or if something doesn't work with your existing C++ tools, it may be because it's a newer addition.
This icon flags proposed additions to the C++ 2026 standard. These features are the newest, so they might not be implemented in all compilers available as of this writing.
As you work on the concepts presented in this guide, this icon serves as an occasional reminder that there is additional content posted online at www.dummies.com/go/cplusplus8e to take you even further on your programming journey. I'd tell you more, but that's the subject of the very next section.
Beyond the Book
C++ For Dummies, 8th Edition, includes the following goodies online for easy download:
- The Cheat Sheet, available online, provides an overview of C++ grammar in one (fairly) easy-to-read page. Just make your way to
www.dummies.comand enter C++ For Dummies in the handy search box. If you're a beginner, you can print the Cheat Sheet and keep it handy as you work through later chapters. Eventually, C++ syntax becomes second nature and you'll no longer need the Cheat Sheet. - The source code for the examples in this book can be downloaded from
www.dummies.com/go/cplusplus8e. The programs are organized by chapter number. - Bonus chapters can also be found online that take you even deeper into C++. Three bonus chapters there...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.