Will | C++ | Buch | 978-1-4932-2626-9 | sack.de

Buch, Englisch, 1089 Seiten, Format (B × H): 178 mm x 254 mm, Gewicht: 1870 g

Will

C++

The Comprehensive Guide
1. Auflage 2025
ISBN: 978-1-4932-2626-9
Verlag: Rheinwerk Verlag GmbH

The Comprehensive Guide

Buch, Englisch, 1089 Seiten, Format (B × H): 178 mm x 254 mm, Gewicht: 1870 g

ISBN: 978-1-4932-2626-9
Verlag: Rheinwerk Verlag GmbH


If you need to know C++, look no further! This comprehensive guide has everything you need to master the modern C++23 language, from syntax fundamentals to advanced development concepts. Follow practical code examples as you learn object-oriented programming, work with standard library containers, program concurrent applications, and more. Don’t just learn how to code—learn how to code better with expert tips and guidance on the rules of compact, secure, and efficient code.

In this book, you’ll learn about:

a. Basic to Advanced Programming
Master C++ programming from the ground up. Learn how to code with building blocks such as comments, variables, and functions, and then walk through object-oriented programming. Graduate to advanced concepts, including pointers and templates.

b. The Standard Library
Dive into the C++ standard library, including an in-depth guide to containers: what they can do, what they can’t do, and how to choose the right one for your scenario. Work with streams and files, explore unique syntax, and implement concurrency using threads.

c. Good Coding Practices
Write effective, sustainable code. Dedicated chapters provide guidelines, techniques, and tips for good coding. Put theory into practice with numerous sample programs that you can download to help jump-start your own projects.

Highlights include:

1) Language basics
2) Statements and expressions
3) Structures and classes
4) Object-oriented programming
5) Containers
6) Threading
7) Error handling
8) Testing
9) Pointers
10) Interface to C
11) Templates
12) Best practices

Will C++ jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


. Preface. 27

PART I. Fundamentals. 31

1. C++: The Comprehensive Guide. 33

1.1. New and Modern. 33

1.2. “Dan” Chapters. 34

1.3. Presentation in This Book. 35

1.4. Formatting Used. 35

1.5. Let’s Talk Lingo. 36

2. Programming in C++. 37

2.1. Compiling. 38

2.2. Translation Phases. 39

2.3. Current Compilers. 39

2.4. Development Environments. 41

2.5. The Command Line under Ubuntu. 43

2.6. The Visual Studio Code IDE under Windows. 46

2.7. Speed Up the Sample Program. 53

3. C++ for Newcomers. 55

4. The Basic Building Blocks of C++. 63

4.1. A Quick Overview. 66

4.2. A Detailed Walkthrough. 70

4.3. Operators. 97

4.4. Built-In Data Types. 111

4.5. Undefined Behavior. 149

5. Good Code, 1st Dan: Writing Readable Code. 151

5.1. Comments. 151

5.2. Documentation. 152

5.3. Indentations and Line Length. 153

5.4. Lines per Function and File. 154

5.5. Brackets and Spaces. 154

5.6. Names. 156

6. Higher Data Types. 159

6.1. The String Type “string”. 160

6.2. Streams. 166

6.3. Container and Pointer. 172

6.4. The Simple Sequence Containers. 174

6.5. Algorithms. 179

6.6. Pointers and C-Arrays. 180

7. Functions. 181

7.1. Declaration and Definition of a Function. 182

7.2. Function Type. 183

7.3. Using Functions. 184

7.4. Defining a Function. 185

7.5. More about Parameters. 186

7.6. Functional Body. 190

7.7. Converting Parameters. 192

7.8. Overloading Functions. 194

7.9. Default Parameter. 196

7.10. Arbitrary Number of Arguments. 198

7.11. Alternative Notation for Function Declaration. 198

7.12. Specialties. 199

8. Statements in Detail. 203

8.1. The Statement Block. 206

8.2. The Empty Statement. 208

8.3. Declaration Statement. 209

8.4. The Expression Statement. 211

8.5. The “if” Statement. 212

8.6. The “while” Loop. 216

8.7. The “do-while” Loop. 218

8.8. The “for” Loop. 219

8.9. The Range-Based “for” Loop. 221

8.10. The “switch” Statement. 222

8.11. The “break” Statement. 227

8.12. The “continue” Statement. 228

8.13. The “return” Statement. 228

8.14. The “goto” Statement. 229

8.15. The “try-catch” Block and “throw”. 231

8.16. Summary. 232

9. Expressions in Detail. 233

9.1. Calculations and Side Effects. 234

9.2. Types of Expressions. 235

9.3. Literals. 236

9.4. Identifiers. 237

9.5. Parentheses. 237

9.6. Function Call and Index Access. 238

9.7. Assignment. 238

9.8. Type Casting. 240

10. Error Handling. 243

10.1. Error Handling with Error Codes. 245

10.2. What Is an Exception?. 248

10.3. Minor Error Handling. 251

10.4. Throwing the Exception Again: “rethrow”. 251

10.5. The Order in “catch”. 252

10.6. Types for Exceptions. 254

10.7. When an Exception Falls Out of “main”. 255

11. Good Code, 2nd Dan: Modularization. 257

11.1. Program, Library, Object File. 257

11.2. Modules. 258

11.3. Separating Functionalities. 259

11.4. A Modular Example Project. 260

PART II. Object-Oriented Programming and More. 273

12. From Structure to Class. 275

12.1. Initialization. 278

12.2. Returning Custom Types. 279

12.3. Methods Instead of Functions. 280

12.4. The Better “print”. 283

12.5. An Output Like Any Other. 285

12.6. Defining Methods Inline. 286

12.7. Separate Implementation and Definition. 287

12.8. Initialization via Constructor. 288

12.9. Struct or Class?. 295

12.10. Interim Recap. 299

12.11. Using Custom Data Types. 300

12.12. Type Inference with “auto”. 315

12.13. Custom Classes in Standard Containers. 319

13. Namespaces and Qualifiers. 323

13.1. The “std” Namespace. 324

13.2. Anonymous Namespace. 327

13.3. “static” Makes Local. 329

13.4. “static” Likes to Share. 330

13.5. Remote Initialization or “static inline” Data Fields. 332

13.6. Guaranteed to Be Initialized at Compile Time with “constinit”. 333

13.7. “static” Makes Permanent. 333

13.8. “inline namespace”. 335

13.9. Interim Recap. 336

13.10. “const”. 337

13.11. Volatile with “volatile”. 357

14. Good Code, 3rd Dan: Testing. 361

14.1. Types of Tests. 361

14.2. Frameworks. 368

14.3. Boost.Test. 372

14.4. Helper Macros for Assertions. 376

14.5. An Example Project with Unit Tests. 379

15. Inheritance. 391

15.1. Relationships. 392

15.2. Inheritance in C++. 394

15.3. Has-a versus Is-a. 395

15.4. Finding Commonalities. 396

15.5. Derived Types Extend. 398

15.6. Overriding Methods. 399

15.7. How Methods Work. 400

15.8. Virtual Methods. 402

15.9. Constructors in Class Hierarchies. 404

15.10. Type Conversion in Class Hierarchies. 405

15.11. When to Use Virtual?. 407

15.12. Other Designs for Extensibility. 409

16. The Lifecycle of Classes. 411

16.1. Creation and Destruction. 412

16.2. Temporary: Short-Lived Values. 414

16.3. The Destructor to the Constructor. 416

16.4. Yoda Condition. 420

16.5. Construction, Destruction, and Exceptions. 421

16.6. Copy. 423

16.7. Assignment Operator. 426

16.8. Removing Methods. 429

16.9. Move Operations. 430

16.10. Operators. 435

16.11. Custom Operators in a Data Type. 438

16.12. Special Class Forms. 446

17. Good Code, 4th Dan: Security, Quality, and Sustainability. 451

17.1. The Rule of Zero. 451

17.2. Resource Acquisition Is Initialization. 457

18. Specials for Classes. 467

18.1. Allowed to See Everything: “friend” Classes. 467

18.2. Nonpublic Inheritance. 471

18.3. Signature Classes as Interfaces. 477

18.4. Multiple Inheritance. 481

18.5. Diamond-Shaped Multiple Inheritance: “virtual” for Class Hierarchies. 490

18.6. Literal Data Types: “constexpr” for Constructors. 495

19. Good Code, 5th Dan: Classical Object-Oriented Design. 497

19.1. Objects in C++. 499

19.2. Object-Oriented Design. 500

PART III. Advanced Topics. 519

20. Pointers. 521

20.1. Addresses. 522

20.2. Pointer. 523

20.3. Dangers of Aliasing. 525

20.4. Heap Memory and Stack Memory. 526

20.5. Smart Pointers. 530

20.6. Raw Pointers. 539

20.7. C-Arrays. 543

20.8. Iterators. 550

20.9. Pointers as Iterators. 551

20.10. Pointers in Containers. 552

20.11. The Exception: When Cleanup Is Not Necessary. 552

21. Macros. 555

21.1. The Preprocessor. 556

21.2. Beware of Missing Parenthesis. 560

21.3. Feature Macros. 561

21.4. Information about the Source Code. 561

21.5. Warning about Multiple Executions. 562

21.6. Type Variability of Macros. 563

21.7. Summary. 566

22. Interface to C. 567

22.1. Working with Libraries. 568

22.2. C Header. 569

22.3. C Resources. 572

22.4. “void” Pointers. 572

22.5. Reading Data. 573

22.6. The Main Program. 575

22.7. Summary. 575

23. Templates. 577

23.1. Function Templates. 578

23.2. Function Templates in the Standard Library. 588

23.3. A Class as a Function. 593

23.4. C++ Concepts. 609

23.5. Template Classes. 616

23.6. Templates with Variable Argument Count. 630

23.7. Custom Literals. 634

PART IV. The Standard Library. 645

24. Containers. 647

24.1. Basics. 648

24.2. Iterator Basics. 660

24.3. Allocators: Memory Issues. 665

24.4. Container Commonalities. 668

24.5. An Overview of the Standard Container Classes. 669

24.6. The Sequential Container Classes. 673

24.7. Associative and Ordered. 716

24.8. Only Associative and Not Guaranteed. 749

24.9. Container Adapters. 779

24.10. Special Cases: “string”, “basic_string”, and “vector”. 781

24.11. Special Cases: “vector”, “array”, and “bitset”. 782

24.12. Special Case: Value Array with “valarray”. 786

25. Container Support. 795

25.1. Algorithms. 796

25.2. Iterators and Ranges. 798

25.3. Iterator Adapter. 800

25.4. Algorithms of the Standard Library. 800

25.5. Parallel Execution. 802

25.6. Lists of Algorithm Functions and Range Adapters. 805

25.7. Element-Linking Algorithms from “” and “”. 831

25.8. Copy instead of Assignment: Values in Uninitialized Memory Areas. 838

25.9. Custom Algorithms. 840

25.10. Writing Custom Views and Range Adapters. 842

26. Good Code, 6th Dan: The Right Container for Each Task. 845

26.1. All Containers Arranged by Aspects. 845

26.2. Recipes for Containers. 850

26.3. Implementing Algorithms That Are Specialized Depending on the Container. 856

27. Streams, Files, and Formatting. 857

27.1. Input and Output Concept with Streams. 857

27.2. Global, Predefined Standard Streams. 858

27.3. Methods for Stream Input and Output. 860

27.4. Error Handling and Stream States. 864

27.5. Manipulating and Formatting Streams. 867

27.6. Streams for File Input and Output. 879

27.7. Streams for Strings. 892

27.8. Stream Buffers. 898

27.9. “filesystem”. 900

27.10. Formatting. 902

28. Standard Library: Extras. 909

28.1. “pair” and “tuple”. 909

28.2. Regular Expressions. 917

28.3. Randomness. 926

28.4. Mathematical. 935

28.5. System Error Handling with “system_error”. 960

28.6. Runtime Type Information: “” and “”. 968

28.7. Helper Classes around Functors: “”. 972

28.8. “optional” for a Single Value or No Value. 980

28.9. “variant” for One of Several Types. 980

28.10. “any” Holds Any Type. 982

28.11. Special Mathematical Functions. 983

28.12. Fast Conversion with “”. 984

29. Threads: Programming with Concurrency. 987

29.1. C++ Threading Basics. 988

29.2. Shared Data. 1005

29.3. Other Synchronization Options. 1021

29.4. In Its Own Storage with “thread_local”. 1024

29.5. Waiting for Events with “condition_variable”. 1025

29.6. Waiting Once with “future”. 1030

29.7. Atomics. 1040

29.8. Coroutines. 1046

29.9. Summary. 1051

30. Good Code, 7th Dan: Guidelines. 1055

30.1. Guideline Support Library. 1056

30.2. C++ Core Guidelines. 1056

. Appendices. 1069

A. Cheat Sheet. 1069

B. The Author. 1073

. Index. 1075


Will, Torsten T.
Torsten T. Will is a C++ expert who has been fascinated by the language since earning his degree in computer science. In addition to C++, he has worked with numerous other languages over the course of his career, including Python, Java, and Haskell. Since 2004, he has contributed his expertise to c’t, a German magazine for computer technology, where he writes about C++ and Python. In his free time, he enjoys photography.



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.