Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Frances Buontempo

Rating No ratings yet

You know how to code, but you're ready to level up. You've heard about the power and performance of C++, a language vital to fields like AI, game development, and high-performance computing. But where do you even start? Existing resources are outdated or overly academic, or they assume a deep understanding of C. You need a guide that respects your existing skills and gets you coding fast with modern C++. This book cuts through the noise, focusing on the essential elements of C++ with hands-on projects that quickly build your skills and confidence. Author and C++ expert Frances Buontempo gets you up to speed quickly with the latest features and best practices of the language, preparing you for more advanced exploration. - Write clean and efficient C++ code - Understand core concepts and syntax - Apply various programming approaches, from OOP to functional styles - Read and understand complex C++ definitions and resources

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical, hands-on introduction to modern C++ (C++23) for programmers who already know how to code but are new to the language—covering everything from basic syntax and input handling to classes, variants, and templates through a fun trading-game project. 【Book Arc】 - **Opening (~0%–13%)**: Sets up the book's philosophy—you don't need to learn C first—and walks through installing tools, choosing an editor, and writing your first "Hello, World!" program. Covers fundamental syntax: functions, statements, the `main` function, and basic types. - **Early (~13%–32%)**: Dives into variables and keyboard input, teaching stream handling with `std::cin`, error detection using `eof` and `peek`, and function design. Introduces testing with `assert`, pass-by-reference vs. pass-by-value, and the importance of C++'s strong typing. - **Middle (~32%–48%)**: Explores error handling in depth—exceptions vs. `std::expected`—and introduces loops for handling multiple inputs. Moves into containers, focusing on `std::vector` with iterators, insertion, erasure, and capacity management. - **Middle (~48%–65%)**: Covers strings (both C-style and C++ `std::string`), file I/O as streams, and the transition into object-oriented programming with classes. Establishes the trading-game project as a recurring hands-on exercise. - **Late (~65%–85%)**: Delves into classes in detail: virtual functions, inheritance, abstract base classes, and derived types. Addresses advanced topics like virtual destructors and object slicing, then introduces `std::variant` and `std::visit` as modern alternatives to traditional OOP patterns. - **Ending (~85%–100%)**: Wraps up with templates and lookup tables (`std::unordered_map`), providing a brief but sufficient introduction to writing your own templates. Concludes by acknowledging there's more to learn while affirming the reader now has a solid foundation. 【Key Takeaways】 - **Modern C++ is accessible without prior C knowledge** (Opening): The book explicitly debunks the myth that you must learn C first, making C++ approachable for programmers from other languages. (Early) - **Streams are the backbone of I/O** (Early): Understanding `std::cin`, `std::cout`, and manipulators like `std::endl` (which flushes the buffer) helps you handle input/output robustly and debug effectively. (Early) - **Strong typing is your friend** (Early): C++'s type system catches errors at compile time—like passing an `int` where a `double&` is expected—saving you from runtime surprises. (Early) - **Error handling has modern options** (Middle): Beyond traditional exceptions, `std::expected` lets you return either a value or an error message, giving you explicit control over failure cases without throwing. (Middle) - **Containers manage memory for you** (Middle): `std::vector` handles dynamic resizing automatically, and functions like `insert`, `erase`, and `shrink_to_fit` give you fine-grained control over data and capacity. (Middle) - **Classes enable multiple paradigms** (Late): C++ supports OOP but doesn't force it—you can write object-oriented, functional, or procedural code, and the book shows how to choose what fits your design. (Late) - **Modern alternatives to classic OOP** (Late): `std::variant` with `std::visit` offers a type-safe way to handle a fixed set of types, often cleaner than deep inheritance hierarchies. (Late) - **Templates are powerful but approachable** (Ending): A short introduction is enough to understand how to write your own templates, opening the door to generic programming. (Ending) 【Reading Tips】 - **Type the code as you read**: The book explicitly encourages this—hands-on practice with the trading-game project is essential for retention and understanding. - **Skim the tool-installation sections if you're experienced**: If you already have a C++ toolchain or prefer an IDE, you can jump ahead to the syntax chapters without missing core content. - **Deep-read the error-handling chapters**: The distinction between exceptions and `std::expected` is subtle but crucial for writing robust code—pay close attention to the trade-offs. - **Use Compiler Explorer (Godbolt) for quick experiments**: The book recommends this online tool for testing snippets without local setup, which is great for trying variations on examples. - **Don't skip the "In Depth" sections**: These provide the "why" behind the "how," especially for virtual functions, slicing, and `std::variant`—they'll save you from common pitfalls later. 【Coverage Limits】 This guide synthesizes the opening through middle sections (roughly 0–52% of the book). The later chapters on classes, variants, and templates are summarized from the table of contents and brief excerpts; detailed content on those topics is not fully covered here.
Excerpt 1
254 Defining an Abstract Base Class 254 A Derived Class 255 Using Derived Classes 258 A New Trading Game 261 Adding Another Derived Type 264 Virtual Function...
View in text
Excerpt 2
with the GNU Compiler Collection (GCC). GCC can build sev‐ eral languages and provides a tool called g++ to build C++ code. See if you have g++ by opening a...
View in text
Excerpt 3
le trying to match the argument list '(std::istream, int)' The compiler sees a function that expects a reference to a double, so it complains when you send i...
View in text
Excerpt 4
x, first, and then x is incremented. So, x is 1 and y is 0. There are a few cases where using preincrement rather than postincrement makes a difference, but...
View in text
Excerpt 5
emove the elements. You therefore see an assertion failure: Assertion 'got.size() == 1' failed. Let’s make the test pass. You will use std::remove_if. The ca...
View in text
Excerpt 6
the <ios> header before you stream out the bool, like this: std::cout << "Required profit possible " << std::boolalpha << possible << '\n'; boolalpha is a ma...
View in text
Excerpt 7
ace for the count you need and then put the prices in using another algorithm called std::generate_n. Like std::generate, this algorithm takes a function to...
View in text
Excerpt 8
"How are you?" for(auto message: messages) { std::cout << message << '\n'; } If you try this, you will see both messages print. Avoid using it in your code,...
View in text
Tags
AI categories
C++Programming LanguageProgramming
ISBN: 1098178149
Publisher: O'Reilly Media
Publish Year: 2026
Language: English
Pages: 348
File Format: PDF
File Size: 21.4 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…