June 2025
Intermediate to advanced
1093 pages
33h 24m
English
The line with the temporary value is particularly noteworthy. With MyValue{}, you create an instance of the class, which is then passed as a parameter to function. However, the instance does not get a variable name. Instead, you create a temporary value (also called a temp-value). As such, this value disappears at the end of the statement—as a rule of thumb, at the next semicolon.
When you create a temp-value, it is not a declaration, but an expression. Therefore, you can use it directly—for example, as a parameter for a function.
There are other ways to generate temp-values. For example, an automatic type conversion can lead to this, as shown in the following listing when calling length().
Read now
Unlock full access