1/21
Vocabulary flashcards covering C++ type rules, casting, overflow, and I/O basics from the lecture notes.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Integer arithmetic
When both operands are integers; division truncates toward zero, discarding any fractional parts.
Floating-point promotion
If at least one operand is floating point (float, double, long double), the entire operation is promoted to floating point to preserve fractions.
Usual arithmetic conversions
Rules that determine the resulting type in mixed-type expressions; the stronger type wins (double > float > integer).
Implicit casting
Compiler automatically promotes or converts types during evaluation without explicit syntax.
Explicit casting
You manually request a type change using a cast; examples include static_cast
static_cast
A C++ explicit cast that converts a value to a target type; used to forcibly change a value's type.
Overflow
When a value cannot fit in the available bits of the data type; results can wrap around or become incorrect; may require a larger type.
Large-number guideline
If a quantity is around 2,000,000,000 or larger, avoid int; use a larger type like long int or double instead.
Left-to-right evaluation
C++ evaluates expressions from left to right and applies type rules at each step.
Post-increment
x++ returns the current value, then increments x after the expression is evaluated.
Pre-increment
++x increments x first, then the new value is used in the expression.
IO streams
C++ console I/O uses std::cin (input), std::cout (output), and std::cerr (error); these are buffered.
cout
Standard output stream; used with the << operator to print to the console.
cin
Standard input stream; used with the >> operator to read from the console; reads until whitespace.
cerr
Standard error stream; separate from normal output for error messages.
using namespace std
Directive to bring standard library names into the global namespace; commonly placed at the top of a file.
include directive
Preprocessor command to copy header declarations into your file; standard headers use angle brackets <>; user headers use quotes.
header guards
Preprocessor technique (#ifndef, #define, #endif) to prevent multiple inclusions of the same header.
std::string
Standard string type from the string library; dynamic, safe for text handling.
String concatenation
Operator + merges two std::string objects into one string.
Extraction operator (>>)
Reads input from standard input into a variable; stops at whitespace; to read multiple words, chain extractions.
Output operator (<<)
Writes data to standard output via std::cout; used with strings and values.