Skip to content

Fix phrase related to "cout" but not relevant for print. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 01-string-and-character-literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ While little hands make vain pretence
Our wanderings to guide.
```

* Now use a (non-raw) string literal for each line and a single call to `print()` with suitable escape characters. What happens if you remove all of the stream insertion operators *except* for the first? (Explanation: *concatenation* of adjacent string literals is automatically performed by the pre-processor.)
* Now use a (non-raw) string literal for each line and a single call to `print()` with suitable escape characters. You concatenate the string literals without any operator: *concatenation* of adjacent string literals is automatically performed by the pre-processor.

* Modify `01-title.cpp` to output the title of your favorite book or film centered on the console window (assume an 80 character fixed width, and change the size of the console window if different).

Expand All @@ -156,7 +156,7 @@ The following table lists C++ types, sizes, target encodings, literals and objec
| char32_t | 32 | UTF-32 | U"abcd" | U'a' | UR"(abcd)" | u32string | n/a | no |
| wchar_t | 16/32 | n/a + | L"abcd" | L'a' | LR"(abcd)" | wstring | wcout/wcerr | no |

&#42; An explicit cast to type `char` in `operator<<` may be required when using `cout`/`cerr`, for example: `cout << static_cast<char>(u8"Hello \u20AC!\n");`.
&#42; An explicit cast to type `char` in `operator<<` may be required when using `cout`/`cerr`, for example: `cout << reinterpret_cast<const char*>(u8"Hello \u20AC!\n");`.

&#43; The `wchar_t` encoding and streams under Windows are 16-bit and support UTF-16.

Expand Down
5 changes: 4 additions & 1 deletion 02-variables-scopes-and-namespaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ In fact, `constexpr` expressions can be complex with recent compilers, as long a
#include <cmath>
using namespace std;

// Note: currently, not all compilers mark `acos` as a
// constexpr function in cmath. The following line might
// not compile with `clang++` for example.
constexpr double PI1 = acos(-1.0);
constexpr double PI2 = 22.0 / 7.0;

Expand All @@ -480,7 +483,7 @@ int main() {
}
```

(Hint: this program is the first to require an additional header to `<print>`; you may need to add `-lm` to the compile command under Linux/MacOS in order to link in the math library containing the `acos()` function.)
(Hint: this program is the first to require an additional header to `<print>`; you may need to add `-lm` to the compile command under Linux in order to link in the math library containing the `acos()` function.)

**Experiment**

Expand Down
2 changes: 1 addition & 1 deletion 04-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ The keyword `noexcept` is used to declare that a function is guaranteed to not t
#include <stdexcept>
using namespace std;

void throw_if_zero(int i) {
void throw_if_zero(int i) noexcept {
if (!i) {
throw runtime_error("found a zero");
}
Expand Down