`short` — C++ Keyword
`short` — C++ Keyword
The short keyword in C++: a signed integer type at least 16 bits wide.
`short` — C++ Keyword
The short keyword in C++: a signed integer type at least 16 bits wide.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
shortShorthand for short int. A signed integer type guaranteed to be at least 16 bits wide. On virtually all modern platforms it is exactly 16 bits.
short s;
short int s;
unsigned short us;
signed short ss;
#include <print>
#include <climits>
int main() {
short s = 32767;
std::println("{}", s); // 32767
unsigned short us = 65535u;
std::println("{}", us); // 65535
std::println("min: {} max: {}", SHRT_MIN, SHRT_MAX);
// min: -32768 max: 32767
// Integer arithmetic promotes short to int
short a = 100, b = 200;
auto sum = a + b; // type is int, not short
std::println("{}", sum); // 300
}
int for general arithmetic; use short only when memory layout or ABI compatibility with a specific format requires it.std::int16_t / std::uint16_t from <cstdint>.shortint main() {
// Pick one facility from this reference page.
// Write the smallest program that exercises its main precondition,
// complexity rule, or lifetime constraint before scaling up.
return 0;
}