- Broschiertes Buch
- Merkliste
- Auf die Merkliste
- Bewerten Bewerten
- Teilen
- Produkt teilen
- Produkterinnerung
- Produkterinnerung
Ready to learn programming with less effort and more fun? Then do it the lazy way! C++20 for Lazy Programmers uses humor and fun to make you actually willing to read and eager to do the projects as you master the popular and powerful C++ language. Along the way it includes many features from the new C++20 standard, such as ranges, spans, format strings, the "spaceship" operator, and concepts (template parameter requirements), and provides brief introductions to modules and coroutines. With this unique method, you'll stretch your abilities with a variety of projects, including your own C++…mehr
Andere Kunden interessierten sich auch für
- Carlos OliveiraPractical C++20 Financial Programming42,99 €
- Carlos OliveiraOptions and Derivatives Programming in C++2035,99 €
- Stephan RothClean C++2031,99 €
- Daniel KusswurmModern Parallel Programming with C++ and Assembly Language48,99 €
- Alejandro Serrano MenaPractical Haskell44,99 €
- Adam FreemanPro Go58,99 €
- Iuliana CosminaJava 17 for Absolute Beginners41,99 €
-
-
-
Ready to learn programming with less effort and more fun? Then do it the lazy way! C++20 for Lazy Programmers uses humor and fun to make you actually willing to read and eager to do the projects as you master the popular and powerful C++ language. Along the way it includes many features from the new C++20 standard, such as ranges, spans, format strings, the "spaceship" operator, and concepts (template parameter requirements), and provides brief introductions to modules and coroutines.
With this unique method, you'll stretch your abilities with a variety of projects, including your own C++ arcade game. You'll construct your own classes, templates, and abstract data types. After reading and using this book you'll be ready to build real-world C++ applications and game projects on your own.
What You Will Learn:
The brand-new C++20 standardProgramming graphics and games with the SDL library, using SSDL, the "Simple SDL" wrapper libraryHow to use the most common C++ compilers -- Visual Studio for Windows, and g++ (with Unix or MinGW) -- and their associated debuggers"Anti-bugging" for easy fixes to common problems Sound practices for becoming a productive programmerHow to make your own big projects, including a C++-based arcade game The built-in Standard Template Library (STL) functions and classes for easy and efficient programmingPowerful data types including strings, stacks, vectors, and linked lists -- not by reading about them but by building them -- preparing you further for a career in programming
Who This Book Is For
All who are new to C++, either self-learners or students in college-level courses.
With this unique method, you'll stretch your abilities with a variety of projects, including your own C++ arcade game. You'll construct your own classes, templates, and abstract data types. After reading and using this book you'll be ready to build real-world C++ applications and game projects on your own.
What You Will Learn:
The brand-new C++20 standardProgramming graphics and games with the SDL library, using SSDL, the "Simple SDL" wrapper libraryHow to use the most common C++ compilers -- Visual Studio for Windows, and g++ (with Unix or MinGW) -- and their associated debuggers"Anti-bugging" for easy fixes to common problems Sound practices for becoming a productive programmerHow to make your own big projects, including a C++-based arcade game The built-in Standard Template Library (STL) functions and classes for easy and efficient programmingPowerful data types including strings, stacks, vectors, and linked lists -- not by reading about them but by building them -- preparing you further for a career in programming
Who This Book Is For
All who are new to C++, either self-learners or students in college-level courses.
Produktdetails
- Produktdetails
- Verlag: Apress / Springer, Berlin
- Artikelnr. des Verlages: 978-1-4842-6305-1
- 2. Aufl.
- Seitenzahl: 677
- Erscheinungstermin: 12. Dezember 2020
- Englisch
- Abmessung: 254mm x 178mm x 37mm
- Gewicht: 1308g
- ISBN-13: 9781484263051
- ISBN-10: 1484263057
- Artikelnr.: 59853076
- Verlag: Apress / Springer, Berlin
- Artikelnr. des Verlages: 978-1-4842-6305-1
- 2. Aufl.
- Seitenzahl: 677
- Erscheinungstermin: 12. Dezember 2020
- Englisch
- Abmessung: 254mm x 178mm x 37mm
- Gewicht: 1308g
- ISBN-13: 9781484263051
- ISBN-10: 1484263057
- Artikelnr.: 59853076
Will Briggs, PhD is a professor of computer science at the University of Lynchburg in Virginia. He has 20+ years of experience teaching C++, 12 of them using earlier drafts of this book, and about as many years teaching other languages including C, LISP, Pascal, PHP, PROLOG, and Python. His primary focus is teaching of late while also active in research in artificial intelligence.
Introduction1-1
1Getting started1-91.1A simple program1-91.2Creating an SSDL project1-121.3Shapes and the functions that draw them1-271.4consts and colors1-351.5Text1-37 Prominent examples from this chapter: a drawing of a bug's head; a neatly printed poem.
2Images and sound2-432.1Images and changing window characteristics2-432.2Multiple images together2-482.3Adding transparency with GIMP2-502.4Sound2-54Example: a slide show (Your yard gnome's travel pics).
3Math: types, operations, consts, and math functions3-563.1Variables3-563.2const, constexpr, constinit3-573.3Math operators3-593.4Built-in functions and casting3-62Examples: diver on a diving board; a 5-pointed star.C++20 updates: constexpr, constinit.
After this chapter, constexpr/constinit show up in most examples.
4Mouse, and if4-674.1Mouse functions4-674.2if4-694.3Boolean values and variables4-734.4A hidden-object game4-75Example: The hidden-object game.
5Loops and text input5-795.1Keyboard input5-795.2while and do-while5-815.3for loops5-855.4chars and cctype5-905.5switch5-94Examples: the Monty Hall problem; menus.
6Algorithms and the development process6-976.1Adventures in robotic cooking6-976.2Writing a program from start to finish6-100
Example: a bullseye pattern.
7Functions7-1067.1Functions that return values7-1067.2Functions that return nothing7-1097.3Global variables and why they're evil7-1117.4How to write a function in four easy steps (and call it in one)7-1137.5Why have functions, anyway?7-117Example: a multi-frame comic (illustrates code reuse).
8Functions (Continued)8-1268.1Random numbers8-1268.2Boolean functions8-1318.3Multiple values provided: using & parameters8-1338.4Identifier scope8-1388.5A final note on algorithms8-140 Examples: various functions using random number generation.
9Using the debugger9-1419.1A flawed program9-1419.2Breakpoints and watched variables9-1459.3Fixing the stripes9-1459.4Going into functions9-1499.4Fixing the stars9-1499.4Wrap-up9-1509.4Other debugging techniques9-1539.4More on antibugging9-156
Example: a national flag.
10Arrays and enum class10-15910.1Arrays10-15910.2Arrays as function parameters10-16010.3enum class10-16610.4Multidimensional arrays10-166Examples: monthly temperatures, checkers, tic-tac-toe.C++20 update: using enum class (which significantly improves the usefulness of enum class).
11Animation with structs and sprites11-17311.1struct11-17311.2Making a movie with struct and while11-17611.3Sprites11-182Examples: bouncing balls; a video aquarium.C++20 update: designated initializers for structs.
12Building your own arcade game: input, collisions, and putting it all together12-18812.1Determining input states12-18812.2Events12-19012.3Cooldowns and lifetimes12-19112.4Collisions12-19412.5The big game12-195Examples: an arcade game, and the student's own game.
13Standard I/O and file operations13-20413.1Standard I/O programs in Visual C++ and g++13-20413.2File I/O (optional)13-210Examples: various programs reading/writing text files. Except for Chapter 21 (virtual functions), this and subsequent chapters use standard console I/O, not the SSDL graphics library. If used for a course, this chapter likely ends the first semester, so if students are going into a class with a different textbook, they are ready for the console I/O it will certainly require them to know.
14Character arrays and dynamic memory (pointers)14-22114.1Character arrays14-22114.2Dynamic allocation of arrays.14-22414.3Using the * notation14-228Examples: C's string functions, written as examples or offered as exercises; code with new and deleteC++20 updates: array size deduction in new expressions.
15Classes: the basics15-23215.1Writing classes15-23215.2Constructors15-23515.3const objects, const member functions...15-23915.4...and const parameters15-24115.5Multiple constructors15-24115.6Default parameters for code reuse15-24415.7Date program (so far)15-245Examples: the Date class; the student's own Time class.
16Classes, continued16-24816.1inline functions for efficiency16-24816.2Access functions16-24916.3static members, inline, and constexpr/constinit16-25016.4Separate compilation and include files16-25216.5Multiple-file projects in Microsoft Visual C++16-25716.7Multiple-file projects in g++16-25916.8Final Date program16-264Examples: the Date class; the student's own Time class, continued.C++20 updates: constexpr/consteval member functions; constexpr/constinit data members and their interaction with static.
17Operators, and destructors17-26817.1The basic string class17-26817.2Destructors17-27017.3== and != operators17-27117.3Other comparison operators, using the spaceship operator17-27117.4Assignment operators and *this17-27317.5Arithmetic operators17-27517.6[] and () operators17-27917.7>> and <<: operators that aren't class members17-28117.8++ and --17-28317.9Explicit call to constructor17-28417.10.The final String class17-28517.11#include 17-291Examples: a String class; the student's own Point or Fraction class.C++20 updates: implicit != operator; the three-way "spaceship" () operator.
18Exceptions, recursion, and O notation18-29218.1Exceptions18-29218.1Move constructors and move = (optional)18-29618.2Recursion (optional; used in the next section)18-30018.3Algorithm analysis and O-notation (optional)18-303Examples: a Stack class; a factorial function; binary and linear search.
19Classes, continued: inheritance19-30919.1The basics of inheritance19-30919.2Constructors and destructors19-31219.2Inheritance as a concept19-31219.3An inheritance heirarchy, and public/private inheritance19-31419.4Modules: the modern way to maintain libraries19-314Examples: card games.C++20 update: modules.
20Template functions and classes20-33520.1Function templates20-33520.2The Vector class20-33820.3Making Vector a template20-34120.4Unusual class templates (optional)20-34520.5#include ^t;20-346C++20 updates: concepts; class template argument deduction for aggregates.
21Multiple inheritance and virtual functions21-34721.1Virtual functions21-34721.2Multiple inheritance21-357Example: a Shape class. This chapter uses the SSDL library.C++20 updates: if it fits with the examples, constexpr virtual functions.
22Linked lists22-35922.1What lists are and why have them22-35922.2The (default) constructor22-36322.3push_front22-36322.4pop_front22-36522.5The destructor22-36722.6->: a bit of syntactic sugar22-36722.7A bit more friendly syntax: pointers as conditions22-36722.8The linked list template22-36822.9#include 22-371Example: the List class.
23The Standard Template Library (STL)23-37123.1Iterators23-37123.2Getting really lazy: ranges and auto23-37523.3Initializer lists (optional)23-37623.4algorithm (optional)23-375Example: an extension of the List class to use iterators.C++20 updates: initialization statements in range-based for loops (Section 23.2); std::span (23.2); parenthesized initialization of aggregates (23.3); simplified erase*/remove* functions (23.4).
If this is used for a class, the second semester likely ends with Chapter 19 or 20. Remaining chapters are extras for those who want to go further.
24Building bigger projects24-37724.1Namespaces24-37724.2Conditional compilation24-37824.3Libraries24-378
25History25-38225.1SIMULA 6725-38225.2Smalltalk25-38225.3What "object-oriented" is25-38325.4C25-38325.5C++25-38326.6C++'s evolving standards, C++98 to C++2025-383
26Esoterica (recommended)26-38526.1Formatted output (fmt)26-38526.2Command-line arguments26-38726.3static_cast et al26-38926.4Defaulted constructors and =26-39126.5User-defined literals: let C++ handle your units for you26-39326.6Lambda functions for one-time use26-39526.7Sructured bindings: returning multiple values at once26-39826.8Smart pointers26-40026.9Bit twiddling: &, , and ~26-402
C++20 updates: Formatted output; std::make_shared()'s support for arrays (Section 26.8).
27Esoterica (not so recommended)27-40427.1protected sections27-40427.2Template specialization27-40527.3friends and why you shouldn't have any27-40527.4User-defined conversions27-408
28C28-41228.1Compiling C28-41228.2I/O28-41428.3Parameter passing with *28-42128.4Dynamic memory27-423Examples: programs using C's stdio functions (printf, sscanf, etc.).
29Moving on with SDL29-42429.1A basic program in SDL29-42429.2Compling29-42629.3Further resources29-427
AppendicesA.Setting up SDL and SSDL427B.Operators429C.ASCII codes429D.Escape sequences430E.Basic C standard library432F.SSDL reference435
Index448
References455
1Getting started1-91.1A simple program1-91.2Creating an SSDL project1-121.3Shapes and the functions that draw them1-271.4consts and colors1-351.5Text1-37 Prominent examples from this chapter: a drawing of a bug's head; a neatly printed poem.
2Images and sound2-432.1Images and changing window characteristics2-432.2Multiple images together2-482.3Adding transparency with GIMP2-502.4Sound2-54Example: a slide show (Your yard gnome's travel pics).
3Math: types, operations, consts, and math functions3-563.1Variables3-563.2const, constexpr, constinit3-573.3Math operators3-593.4Built-in functions and casting3-62Examples: diver on a diving board; a 5-pointed star.C++20 updates: constexpr, constinit.
After this chapter, constexpr/constinit show up in most examples.
4Mouse, and if4-674.1Mouse functions4-674.2if4-694.3Boolean values and variables4-734.4A hidden-object game4-75Example: The hidden-object game.
5Loops and text input5-795.1Keyboard input5-795.2while and do-while5-815.3for loops5-855.4chars and cctype5-905.5switch5-94Examples: the Monty Hall problem; menus.
6Algorithms and the development process6-976.1Adventures in robotic cooking6-976.2Writing a program from start to finish6-100
Example: a bullseye pattern.
7Functions7-1067.1Functions that return values7-1067.2Functions that return nothing7-1097.3Global variables and why they're evil7-1117.4How to write a function in four easy steps (and call it in one)7-1137.5Why have functions, anyway?7-117Example: a multi-frame comic (illustrates code reuse).
8Functions (Continued)8-1268.1Random numbers8-1268.2Boolean functions8-1318.3Multiple values provided: using & parameters8-1338.4Identifier scope8-1388.5A final note on algorithms8-140 Examples: various functions using random number generation.
9Using the debugger9-1419.1A flawed program9-1419.2Breakpoints and watched variables9-1459.3Fixing the stripes9-1459.4Going into functions9-1499.4Fixing the stars9-1499.4Wrap-up9-1509.4Other debugging techniques9-1539.4More on antibugging9-156
Example: a national flag.
10Arrays and enum class10-15910.1Arrays10-15910.2Arrays as function parameters10-16010.3enum class10-16610.4Multidimensional arrays10-166Examples: monthly temperatures, checkers, tic-tac-toe.C++20 update: using enum class (which significantly improves the usefulness of enum class).
11Animation with structs and sprites11-17311.1struct11-17311.2Making a movie with struct and while11-17611.3Sprites11-182Examples: bouncing balls; a video aquarium.C++20 update: designated initializers for structs.
12Building your own arcade game: input, collisions, and putting it all together12-18812.1Determining input states12-18812.2Events12-19012.3Cooldowns and lifetimes12-19112.4Collisions12-19412.5The big game12-195Examples: an arcade game, and the student's own game.
13Standard I/O and file operations13-20413.1Standard I/O programs in Visual C++ and g++13-20413.2File I/O (optional)13-210Examples: various programs reading/writing text files. Except for Chapter 21 (virtual functions), this and subsequent chapters use standard console I/O, not the SSDL graphics library. If used for a course, this chapter likely ends the first semester, so if students are going into a class with a different textbook, they are ready for the console I/O it will certainly require them to know.
14Character arrays and dynamic memory (pointers)14-22114.1Character arrays14-22114.2Dynamic allocation of arrays.14-22414.3Using the * notation14-228Examples: C's string functions, written as examples or offered as exercises; code with new and deleteC++20 updates: array size deduction in new expressions.
15Classes: the basics15-23215.1Writing classes15-23215.2Constructors15-23515.3const objects, const member functions...15-23915.4...and const parameters15-24115.5Multiple constructors15-24115.6Default parameters for code reuse15-24415.7Date program (so far)15-245Examples: the Date class; the student's own Time class.
16Classes, continued16-24816.1inline functions for efficiency16-24816.2Access functions16-24916.3static members, inline, and constexpr/constinit16-25016.4Separate compilation and include files16-25216.5Multiple-file projects in Microsoft Visual C++16-25716.7Multiple-file projects in g++16-25916.8Final Date program16-264Examples: the Date class; the student's own Time class, continued.C++20 updates: constexpr/consteval member functions; constexpr/constinit data members and their interaction with static.
17Operators, and destructors17-26817.1The basic string class17-26817.2Destructors17-27017.3== and != operators17-27117.3Other comparison operators, using the spaceship operator17-27117.4Assignment operators and *this17-27317.5Arithmetic operators17-27517.6[] and () operators17-27917.7>> and <<: operators that aren't class members17-28117.8++ and --17-28317.9Explicit call to constructor17-28417.10.The final String class17-28517.11#include 17-291Examples: a String class; the student's own Point or Fraction class.C++20 updates: implicit != operator; the three-way "spaceship" () operator.
18Exceptions, recursion, and O notation18-29218.1Exceptions18-29218.1Move constructors and move = (optional)18-29618.2Recursion (optional; used in the next section)18-30018.3Algorithm analysis and O-notation (optional)18-303Examples: a Stack class; a factorial function; binary and linear search.
19Classes, continued: inheritance19-30919.1The basics of inheritance19-30919.2Constructors and destructors19-31219.2Inheritance as a concept19-31219.3An inheritance heirarchy, and public/private inheritance19-31419.4Modules: the modern way to maintain libraries19-314Examples: card games.C++20 update: modules.
20Template functions and classes20-33520.1Function templates20-33520.2The Vector class20-33820.3Making Vector a template20-34120.4Unusual class templates (optional)20-34520.5#include ^t;20-346C++20 updates: concepts; class template argument deduction for aggregates.
21Multiple inheritance and virtual functions21-34721.1Virtual functions21-34721.2Multiple inheritance21-357Example: a Shape class. This chapter uses the SSDL library.C++20 updates: if it fits with the examples, constexpr virtual functions.
22Linked lists22-35922.1What lists are and why have them22-35922.2The (default) constructor22-36322.3push_front22-36322.4pop_front22-36522.5The destructor22-36722.6->: a bit of syntactic sugar22-36722.7A bit more friendly syntax: pointers as conditions22-36722.8The linked list template22-36822.9#include 22-371Example: the List class.
23The Standard Template Library (STL)23-37123.1Iterators23-37123.2Getting really lazy: ranges and auto23-37523.3Initializer lists (optional)23-37623.4algorithm (optional)23-375Example: an extension of the List class to use iterators.C++20 updates: initialization statements in range-based for loops (Section 23.2); std::span (23.2); parenthesized initialization of aggregates (23.3); simplified erase*/remove* functions (23.4).
If this is used for a class, the second semester likely ends with Chapter 19 or 20. Remaining chapters are extras for those who want to go further.
24Building bigger projects24-37724.1Namespaces24-37724.2Conditional compilation24-37824.3Libraries24-378
25History25-38225.1SIMULA 6725-38225.2Smalltalk25-38225.3What "object-oriented" is25-38325.4C25-38325.5C++25-38326.6C++'s evolving standards, C++98 to C++2025-383
26Esoterica (recommended)26-38526.1Formatted output (fmt)26-38526.2Command-line arguments26-38726.3static_cast et al26-38926.4Defaulted constructors and =26-39126.5User-defined literals: let C++ handle your units for you26-39326.6Lambda functions for one-time use26-39526.7Sructured bindings: returning multiple values at once26-39826.8Smart pointers26-40026.9Bit twiddling: &, , and ~26-402
C++20 updates: Formatted output; std::make_shared()'s support for arrays (Section 26.8).
27Esoterica (not so recommended)27-40427.1protected sections27-40427.2Template specialization27-40527.3friends and why you shouldn't have any27-40527.4User-defined conversions27-408
28C28-41228.1Compiling C28-41228.2I/O28-41428.3Parameter passing with *28-42128.4Dynamic memory27-423Examples: programs using C's stdio functions (printf, sscanf, etc.).
29Moving on with SDL29-42429.1A basic program in SDL29-42429.2Compling29-42629.3Further resources29-427
AppendicesA.Setting up SDL and SSDL427B.Operators429C.ASCII codes429D.Escape sequences430E.Basic C standard library432F.SSDL reference435
Index448
References455
Introduction1-1
1Getting started1-91.1A simple program1-91.2Creating an SSDL project1-121.3Shapes and the functions that draw them1-271.4consts and colors1-351.5Text1-37 Prominent examples from this chapter: a drawing of a bug's head; a neatly printed poem.
2Images and sound2-432.1Images and changing window characteristics2-432.2Multiple images together2-482.3Adding transparency with GIMP2-502.4Sound2-54Example: a slide show (Your yard gnome's travel pics).
3Math: types, operations, consts, and math functions3-563.1Variables3-563.2const, constexpr, constinit3-573.3Math operators3-593.4Built-in functions and casting3-62Examples: diver on a diving board; a 5-pointed star.C++20 updates: constexpr, constinit.
After this chapter, constexpr/constinit show up in most examples.
4Mouse, and if4-674.1Mouse functions4-674.2if4-694.3Boolean values and variables4-734.4A hidden-object game4-75Example: The hidden-object game.
5Loops and text input5-795.1Keyboard input5-795.2while and do-while5-815.3for loops5-855.4chars and cctype5-905.5switch5-94Examples: the Monty Hall problem; menus.
6Algorithms and the development process6-976.1Adventures in robotic cooking6-976.2Writing a program from start to finish6-100
Example: a bullseye pattern.
7Functions7-1067.1Functions that return values7-1067.2Functions that return nothing7-1097.3Global variables and why they're evil7-1117.4How to write a function in four easy steps (and call it in one)7-1137.5Why have functions, anyway?7-117Example: a multi-frame comic (illustrates code reuse).
8Functions (Continued)8-1268.1Random numbers8-1268.2Boolean functions8-1318.3Multiple values provided: using & parameters8-1338.4Identifier scope8-1388.5A final note on algorithms8-140 Examples: various functions using random number generation.
9Using the debugger9-1419.1A flawed program9-1419.2Breakpoints and watched variables9-1459.3Fixing the stripes9-1459.4Going into functions9-1499.4Fixing the stars9-1499.4Wrap-up9-1509.4Other debugging techniques9-1539.4More on antibugging9-156
Example: a national flag.
10Arrays and enum class10-15910.1Arrays10-15910.2Arrays as function parameters10-16010.3enum class10-16610.4Multidimensional arrays10-166Examples: monthly temperatures, checkers, tic-tac-toe.C++20 update: using enum class (which significantly improves the usefulness of enum class).
11Animation with structs and sprites11-17311.1struct11-17311.2Making a movie with struct and while11-17611.3Sprites11-182Examples: bouncing balls; a video aquarium.C++20 update: designated initializers for structs.
12Building your own arcade game: input, collisions, and putting it all together12-18812.1Determining input states12-18812.2Events12-19012.3Cooldowns and lifetimes12-19112.4Collisions12-19412.5The big game12-195Examples: an arcade game, and the student's own game.
13Standard I/O and file operations13-20413.1Standard I/O programs in Visual C++ and g++13-20413.2File I/O (optional)13-210Examples: various programs reading/writing text files. Except for Chapter 21 (virtual functions), this and subsequent chapters use standard console I/O, not the SSDL graphics library. If used for a course, this chapter likely ends the first semester, so if students are going into a class with a different textbook, they are ready for the console I/O it will certainly require them to know.
14Character arrays and dynamic memory (pointers)14-22114.1Character arrays14-22114.2Dynamic allocation of arrays.14-22414.3Using the * notation14-228Examples: C's string functions, written as examples or offered as exercises; code with new and deleteC++20 updates: array size deduction in new expressions.
15Classes: the basics15-23215.1Writing classes15-23215.2Constructors15-23515.3const objects, const member functions...15-23915.4...and const parameters15-24115.5Multiple constructors15-24115.6Default parameters for code reuse15-24415.7Date program (so far)15-245Examples: the Date class; the student's own Time class.
16Classes, continued16-24816.1inline functions for efficiency16-24816.2Access functions16-24916.3static members, inline, and constexpr/constinit16-25016.4Separate compilation and include files16-25216.5Multiple-file projects in Microsoft Visual C++16-25716.7Multiple-file projects in g++16-25916.8Final Date program16-264Examples: the Date class; the student's own Time class, continued.C++20 updates: constexpr/consteval member functions; constexpr/constinit data members and their interaction with static.
17Operators, and destructors17-26817.1The basic string class17-26817.2Destructors17-27017.3== and != operators17-27117.3Other comparison operators, using the spaceship operator17-27117.4Assignment operators and *this17-27317.5Arithmetic operators17-27517.6[] and () operators17-27917.7>> and <<: operators that aren't class members17-28117.8++ and --17-28317.9Explicit call to constructor17-28417.10.The final String class17-28517.11#include 17-291Examples: a String class; the student's own Point or Fraction class.C++20 updates: implicit != operator; the three-way "spaceship" () operator.
18Exceptions, recursion, and O notation18-29218.1Exceptions18-29218.1Move constructors and move = (optional)18-29618.2Recursion (optional; used in the next section)18-30018.3Algorithm analysis and O-notation (optional)18-303Examples: a Stack class; a factorial function; binary and linear search.
19Classes, continued: inheritance19-30919.1The basics of inheritance19-30919.2Constructors and destructors19-31219.2Inheritance as a concept19-31219.3An inheritance heirarchy, and public/private inheritance19-31419.4Modules: the modern way to maintain libraries19-314Examples: card games.C++20 update: modules.
20Template functions and classes20-33520.1Function templates20-33520.2The Vector class20-33820.3Making Vector a template20-34120.4Unusual class templates (optional)20-34520.5#include ^t;20-346C++20 updates: concepts; class template argument deduction for aggregates.
21Multiple inheritance and virtual functions21-34721.1Virtual functions21-34721.2Multiple inheritance21-357Example: a Shape class. This chapter uses the SSDL library.C++20 updates: if it fits with the examples, constexpr virtual functions.
22Linked lists22-35922.1What lists are and why have them22-35922.2The (default) constructor22-36322.3push_front22-36322.4pop_front22-36522.5The destructor22-36722.6->: a bit of syntactic sugar22-36722.7A bit more friendly syntax: pointers as conditions22-36722.8The linked list template22-36822.9#include 22-371Example: the List class.
23The Standard Template Library (STL)23-37123.1Iterators23-37123.2Getting really lazy: ranges and auto23-37523.3Initializer lists (optional)23-37623.4algorithm (optional)23-375Example: an extension of the List class to use iterators.C++20 updates: initialization statements in range-based for loops (Section 23.2); std::span (23.2); parenthesized initialization of aggregates (23.3); simplified erase*/remove* functions (23.4).
If this is used for a class, the second semester likely ends with Chapter 19 or 20. Remaining chapters are extras for those who want to go further.
24Building bigger projects24-37724.1Namespaces24-37724.2Conditional compilation24-37824.3Libraries24-378
25History25-38225.1SIMULA 6725-38225.2Smalltalk25-38225.3What "object-oriented" is25-38325.4C25-38325.5C++25-38326.6C++'s evolving standards, C++98 to C++2025-383
26Esoterica (recommended)26-38526.1Formatted output (fmt)26-38526.2Command-line arguments26-38726.3static_cast et al26-38926.4Defaulted constructors and =26-39126.5User-defined literals: let C++ handle your units for you26-39326.6Lambda functions for one-time use26-39526.7Sructured bindings: returning multiple values at once26-39826.8Smart pointers26-40026.9Bit twiddling: &, , and ~26-402
C++20 updates: Formatted output; std::make_shared()'s support for arrays (Section 26.8).
27Esoterica (not so recommended)27-40427.1protected sections27-40427.2Template specialization27-40527.3friends and why you shouldn't have any27-40527.4User-defined conversions27-408
28C28-41228.1Compiling C28-41228.2I/O28-41428.3Parameter passing with *28-42128.4Dynamic memory27-423Examples: programs using C's stdio functions (printf, sscanf, etc.).
29Moving on with SDL29-42429.1A basic program in SDL29-42429.2Compling29-42629.3Further resources29-427
AppendicesA.Setting up SDL and SSDL427B.Operators429C.ASCII codes429D.Escape sequences430E.Basic C standard library432F.SSDL reference435
Index448
References455
1Getting started1-91.1A simple program1-91.2Creating an SSDL project1-121.3Shapes and the functions that draw them1-271.4consts and colors1-351.5Text1-37 Prominent examples from this chapter: a drawing of a bug's head; a neatly printed poem.
2Images and sound2-432.1Images and changing window characteristics2-432.2Multiple images together2-482.3Adding transparency with GIMP2-502.4Sound2-54Example: a slide show (Your yard gnome's travel pics).
3Math: types, operations, consts, and math functions3-563.1Variables3-563.2const, constexpr, constinit3-573.3Math operators3-593.4Built-in functions and casting3-62Examples: diver on a diving board; a 5-pointed star.C++20 updates: constexpr, constinit.
After this chapter, constexpr/constinit show up in most examples.
4Mouse, and if4-674.1Mouse functions4-674.2if4-694.3Boolean values and variables4-734.4A hidden-object game4-75Example: The hidden-object game.
5Loops and text input5-795.1Keyboard input5-795.2while and do-while5-815.3for loops5-855.4chars and cctype5-905.5switch5-94Examples: the Monty Hall problem; menus.
6Algorithms and the development process6-976.1Adventures in robotic cooking6-976.2Writing a program from start to finish6-100
Example: a bullseye pattern.
7Functions7-1067.1Functions that return values7-1067.2Functions that return nothing7-1097.3Global variables and why they're evil7-1117.4How to write a function in four easy steps (and call it in one)7-1137.5Why have functions, anyway?7-117Example: a multi-frame comic (illustrates code reuse).
8Functions (Continued)8-1268.1Random numbers8-1268.2Boolean functions8-1318.3Multiple values provided: using & parameters8-1338.4Identifier scope8-1388.5A final note on algorithms8-140 Examples: various functions using random number generation.
9Using the debugger9-1419.1A flawed program9-1419.2Breakpoints and watched variables9-1459.3Fixing the stripes9-1459.4Going into functions9-1499.4Fixing the stars9-1499.4Wrap-up9-1509.4Other debugging techniques9-1539.4More on antibugging9-156
Example: a national flag.
10Arrays and enum class10-15910.1Arrays10-15910.2Arrays as function parameters10-16010.3enum class10-16610.4Multidimensional arrays10-166Examples: monthly temperatures, checkers, tic-tac-toe.C++20 update: using enum class (which significantly improves the usefulness of enum class).
11Animation with structs and sprites11-17311.1struct11-17311.2Making a movie with struct and while11-17611.3Sprites11-182Examples: bouncing balls; a video aquarium.C++20 update: designated initializers for structs.
12Building your own arcade game: input, collisions, and putting it all together12-18812.1Determining input states12-18812.2Events12-19012.3Cooldowns and lifetimes12-19112.4Collisions12-19412.5The big game12-195Examples: an arcade game, and the student's own game.
13Standard I/O and file operations13-20413.1Standard I/O programs in Visual C++ and g++13-20413.2File I/O (optional)13-210Examples: various programs reading/writing text files. Except for Chapter 21 (virtual functions), this and subsequent chapters use standard console I/O, not the SSDL graphics library. If used for a course, this chapter likely ends the first semester, so if students are going into a class with a different textbook, they are ready for the console I/O it will certainly require them to know.
14Character arrays and dynamic memory (pointers)14-22114.1Character arrays14-22114.2Dynamic allocation of arrays.14-22414.3Using the * notation14-228Examples: C's string functions, written as examples or offered as exercises; code with new and deleteC++20 updates: array size deduction in new expressions.
15Classes: the basics15-23215.1Writing classes15-23215.2Constructors15-23515.3const objects, const member functions...15-23915.4...and const parameters15-24115.5Multiple constructors15-24115.6Default parameters for code reuse15-24415.7Date program (so far)15-245Examples: the Date class; the student's own Time class.
16Classes, continued16-24816.1inline functions for efficiency16-24816.2Access functions16-24916.3static members, inline, and constexpr/constinit16-25016.4Separate compilation and include files16-25216.5Multiple-file projects in Microsoft Visual C++16-25716.7Multiple-file projects in g++16-25916.8Final Date program16-264Examples: the Date class; the student's own Time class, continued.C++20 updates: constexpr/consteval member functions; constexpr/constinit data members and their interaction with static.
17Operators, and destructors17-26817.1The basic string class17-26817.2Destructors17-27017.3== and != operators17-27117.3Other comparison operators, using the spaceship operator17-27117.4Assignment operators and *this17-27317.5Arithmetic operators17-27517.6[] and () operators17-27917.7>> and <<: operators that aren't class members17-28117.8++ and --17-28317.9Explicit call to constructor17-28417.10.The final String class17-28517.11#include 17-291Examples: a String class; the student's own Point or Fraction class.C++20 updates: implicit != operator; the three-way "spaceship" () operator.
18Exceptions, recursion, and O notation18-29218.1Exceptions18-29218.1Move constructors and move = (optional)18-29618.2Recursion (optional; used in the next section)18-30018.3Algorithm analysis and O-notation (optional)18-303Examples: a Stack class; a factorial function; binary and linear search.
19Classes, continued: inheritance19-30919.1The basics of inheritance19-30919.2Constructors and destructors19-31219.2Inheritance as a concept19-31219.3An inheritance heirarchy, and public/private inheritance19-31419.4Modules: the modern way to maintain libraries19-314Examples: card games.C++20 update: modules.
20Template functions and classes20-33520.1Function templates20-33520.2The Vector class20-33820.3Making Vector a template20-34120.4Unusual class templates (optional)20-34520.5#include ^t;20-346C++20 updates: concepts; class template argument deduction for aggregates.
21Multiple inheritance and virtual functions21-34721.1Virtual functions21-34721.2Multiple inheritance21-357Example: a Shape class. This chapter uses the SSDL library.C++20 updates: if it fits with the examples, constexpr virtual functions.
22Linked lists22-35922.1What lists are and why have them22-35922.2The (default) constructor22-36322.3push_front22-36322.4pop_front22-36522.5The destructor22-36722.6->: a bit of syntactic sugar22-36722.7A bit more friendly syntax: pointers as conditions22-36722.8The linked list template22-36822.9#include 22-371Example: the List class.
23The Standard Template Library (STL)23-37123.1Iterators23-37123.2Getting really lazy: ranges and auto23-37523.3Initializer lists (optional)23-37623.4algorithm (optional)23-375Example: an extension of the List class to use iterators.C++20 updates: initialization statements in range-based for loops (Section 23.2); std::span (23.2); parenthesized initialization of aggregates (23.3); simplified erase*/remove* functions (23.4).
If this is used for a class, the second semester likely ends with Chapter 19 or 20. Remaining chapters are extras for those who want to go further.
24Building bigger projects24-37724.1Namespaces24-37724.2Conditional compilation24-37824.3Libraries24-378
25History25-38225.1SIMULA 6725-38225.2Smalltalk25-38225.3What "object-oriented" is25-38325.4C25-38325.5C++25-38326.6C++'s evolving standards, C++98 to C++2025-383
26Esoterica (recommended)26-38526.1Formatted output (fmt)26-38526.2Command-line arguments26-38726.3static_cast et al26-38926.4Defaulted constructors and =26-39126.5User-defined literals: let C++ handle your units for you26-39326.6Lambda functions for one-time use26-39526.7Sructured bindings: returning multiple values at once26-39826.8Smart pointers26-40026.9Bit twiddling: &, , and ~26-402
C++20 updates: Formatted output; std::make_shared()'s support for arrays (Section 26.8).
27Esoterica (not so recommended)27-40427.1protected sections27-40427.2Template specialization27-40527.3friends and why you shouldn't have any27-40527.4User-defined conversions27-408
28C28-41228.1Compiling C28-41228.2I/O28-41428.3Parameter passing with *28-42128.4Dynamic memory27-423Examples: programs using C's stdio functions (printf, sscanf, etc.).
29Moving on with SDL29-42429.1A basic program in SDL29-42429.2Compling29-42629.3Further resources29-427
AppendicesA.Setting up SDL and SSDL427B.Operators429C.ASCII codes429D.Escape sequences430E.Basic C standard library432F.SSDL reference435
Index448
References455