What does a C++ type determine?
A type determines which values an object or expression can represent and which operations are valid.
Study 02 Variables, Types, and Operators with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What does a C++ type determine?
A type determines which values an object or expression can represent and which operations are valid.
What is the typical difference between `int` and `double`?
`int` represents whole numbers, while `double` represents floating-point numbers with fractional parts.
Why initialize a local variable before reading it?
A variable should be initialized before it is read; an uninitialized local built-in variable does not have a useful automatic value.
What safety benefit does brace initialization provide?
Brace initialization rejects many narrowing conversions, such as assigning `3.14` to an `int`.
What restriction does `const` place on a variable?
A `const` variable cannot be modified after initialization and must be initialized when declared.
How does `constexpr` differ from `const`?
Every `constexpr` variable is constant and is intended for constant expressions; a `const` variable is not necessarily a compile-time constant.
What is a name's scope?
Scope is the region of a program in which a name can be used.
What happens when an inner name shadows an outer name?
An inner declaration with the same spelling hides the declaration from the outer scope within the inner region.
Which cast makes an intentional numeric conversion explicit?
`static_cast` is the preferred general-purpose C++ cast for a well-understood numeric conversion.
How does integer division differ from floating-point division?
For integer operands, division discards the fractional part: `7 / 2` produces `3`, while `7.0 / 2` produces `3.5`.
How do prefix and postfix increment differ?
For `++x`, the variable is incremented before the expression's value is used; for `x++`, its old value is used first.
What is the difference between `==` and `=`?
`==` compares two values for equality, whereas `=` assigns a value to an existing modifiable object.