listings-Chap04-README.md
Listings of Chap04.docx
This is linked summary of the listings. You can also view it on one page.
- Listing 04.1: A very simple C++ program.
- Book: lst-0002-book.cpp
- Godbolt: lst-0002-godb.cpp, https://godbolt.org/z/Mdj7bGvar
- Listing 04.2 This program asks its users for a number.
- Book: lst-0010-book.cpp
- Godbolt: lst-0010-godb.cpp, https://godbolt.org/z/ceT6o5zxd
- Listing 04.3: A very unusually formatted piece of source code.
- Book: lst-0011-book.cpp
- Godbolt: lst-0011-godb.cpp, https://godbolt.org/z/33cc3xfo6
- Listing 04.4 Comments with / and / can extend over several lines or interrupt a program line.
- Book: lst-0012-book.cpp
- Listing 04.5: A custom C++ function.
- Book: lst-0015-book.cpp
- Godbolt: lst-0015-godb.cpp, https://godbolt.org/z/E4W9KhbnK
- Listing 04.6 Prefix operators are executed before the calculation.
- Book: lst-0016-book.cpp
- Godbolt: lst-0016-godb.cpp, https://godbolt.org/z/4Mr6fnaEr
- GodboltId:r5hjrqqK9
- Book: lst-0018-book.cpp
- Godbolt: lst-0018-godb.cpp, https://godbolt.org/z/r5hjrqqK9
- Listing 04.7 A program that consists only of main and return.
- Book: lst-0019-book.cpp
- Listing 04.8: Here you only set the outer curly braces.
- Book: lst-0020-book.cpp
- Listing 04.9 This is what it looks like if you set all curly brackets.
- Book: lst-0021-book.cpp
- Listing 04.10 The “if” is a statement and does not actually require curly brackets.
- Book: lst-0022-book.cpp
- Listing 04.11: It is better to put individual statements in curly brackets.
- Book: lst-0024-book.cpp
- Listing 04.12 Assigning the result of a function call.
- Book: lst-0027-book.cpp
- Listing 04.13 Assigning the result of a calculation.
- Book: lst-0028-book.cpp
- Listing 04.14 An assignment is an expression with the type of the assigned variable.
- Book: lst-0029-book.cpp
- Godbolt: lst-0029-godb.cpp, https://godbolt.org/z/bh1MsPhje
- Listing 04.15 The compiler helps to write correct programs by checking the types.
- Book: lst-0030-book.cpp
- Godbolt: lst-0030-godb.cpp, https://godbolt.org/z/9943MfExc
- Listing 04.16 Variables of type bool can store the result of a comparison.
- Book: lst-0031-book.cpp
- Godbolt: lst-0031-godb.cpp, https://godbolt.org/z/zK9Ke9n48
- Listing 04.17: This is how you can write a C++ string as a literal in the source code.
- Book: lst-0033-book.cpp
- Godbolt: lst-0033-godb.cpp, https://godbolt.org/z/chTTqPjrM
- Listing 04.18: Since C++17, the compiler determines the type parameters of class templates based on the constructor arguments.
- Book: lst-0035-book.cpp
- Godbolt: lst-0035-godb.cpp, https://godbolt.org/z/GbbcnYbqv
- Listing 04.19: You cannot assign anything to some variables; you can only initialize them.
- Book: lst-0036-book.cpp
- Listing 04.20 Instead of = you can use {…} for initialization.
- Book: lst-0037-book.cpp
- Listing 04.21 You can include a namespace to make program text shorter.
- Book: lst-0044-book.cpp
- Listing 04.22 You can also use “using namespace” globally, but you should rarely do so.
- Book: lst-0045-book.cpp
- Listing 04.23 Get individual identifiers with “using”.
- Book: lst-0046-book.cpp
- Listing 04.24 Arithmetic operators in the application.
- Book: lst-0047-book.cpp
- Godbolt: lst-0047-godb.cpp, https://godbolt.org/z/cEGGfoeT7
- Listing 04.25 Programming example for the conversion of an integer into a bit sequence.
- Book: lst-0050-book.cpp
- Godbolt: lst-0050-godb.cpp, https://godbolt.org/z/nMcsbxvvv
- GodboltId:qdY41d5a9
- Book: lst-0051-book.cpp
- Godbolt: lst-0051-godb.cpp, https://godbolt.org/z/qdY41d5a9
- GodboltId:5hqanTeYh
- Book: lst-0053-book.cpp
- Godbolt: lst-0053-godb.cpp, https://godbolt.org/z/5hqanTeYh
- GodboltId:xrMYz93WP
- Book: lst-0062-book.cpp
- Godbolt: lst-0062-godb.cpp, https://godbolt.org/z/xrMYz93WP
- Listing 04.26: You can concatenate several expressions with commas in brackets.
- Book: lst-0063-book.cpp
- Godbolt: lst-0063-godb.cpp, https://godbolt.org/z/rq66cWr3d
- Listing 04.27: The sequence comma can be useful in for loops.
- Book: lst-0064-book.cpp
- Godbolt: lst-0064-godb.cpp, https://godbolt.org/z/vd85f7rMj
- Listing 04.28: Some new data types are used here.
- Book: lst-0068-book.cpp
- Godbolt: lst-0068-godb.cpp, https://godbolt.org/z/MPPsbdq9c
- Listing 04.29: Arithmetic with integers.
- Book: lst-0070-book.cpp
- Godbolt: lst-0070-godb.cpp, https://godbolt.org/z/ebPcdxzvj
- Listing 04.30 Bit operations.
- Book: lst-0071-book.cpp
- Godbolt: lst-0071-godb.cpp, https://godbolt.org/z/jeTs5Exqx
- Listing 04.31 Index variables can be of type “size_t”.
- Book: lst-0073-book.cpp
- Godbolt: lst-0073-godb.cpp, https://godbolt.org/z/zGso3xGcj
- Listing 04.32 “double” cannot always store numbers exactly. Calculating and comparing with “==” is an error.
- Book: lst-0074-book.cpp
- Godbolt: lst-0074-godb.cpp, https://godbolt.org/z/8ae83nPYs
- Listing 04.33: Several ways to mark “double” literals.
- Book: lst-0075-book.cpp
- Godbolt: lst-0075-godb.cpp, https://godbolt.org/z/qx8h7a4j9
- Listing 04.34 Floating-point literals become imprecise at some point.
- Book: lst-0076-book.cpp
- Godbolt: lst-0076-godb.cpp, https://godbolt.org/z/6qfo4oYnr
- Listing 04.35 Among other things, you can discover special values with “fpclassify”.
- Book: lst-0077-book.cpp
- Godbolt: lst-0077-godb.cpp, https://godbolt.org/z/Tvx4qcrE6
- GodboltId:We3oWrcWW
- Book: lst-0080-book.cpp
- Godbolt: lst-0080-godb.cpp, https://godbolt.org/z/We3oWrcWW
- GodboltId:863b1z4GY
- Book: lst-0081-book.cpp
- Godbolt: lst-0081-godb.cpp, https://godbolt.org/z/863b1z4GY
- Listing 04.36 Accumulated time measurement.
- Book: lst-0082-book.cpp
- Godbolt: lst-0082-godb.cpp, https://godbolt.org/z/sEE94bh5K
- Listing 04.37 Closed time calculation.
- Book: lst-0083-book.cpp
- Godbolt: lst-0083-godb.cpp, https://godbolt.org/z/dKPo7andE
- Listing 04.38: You can calculate arithmetically with complex numbers.
- Book: lst-0087-book.cpp
- Godbolt: lst-0087-godb.cpp, https://godbolt.org/z/43rYYeKx9
- Listing 04.39 Output in unspecified order.
- Book: lst-0089-book.cpp
- Godbolt: lst-0089-godb.cpp, https://godbolt.org/z/eW1cfYcGs