`register` — C++ Keyword
`register` — C++ Keyword
The register keyword in C++: deprecated storage class specifier, ignored by modern compilers.
`register` — C++ Keyword
The register keyword in C++: deprecated storage class specifier, ignored by modern compilers.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
registerA historic storage class hint asking the compiler to keep the variable in a CPU register for fast access. Since C++17 the keyword is deprecated; compilers ignore it and modern optimizers automatically allocate hot variables to registers.
register Type name; // valid but deprecated in C++17; removed meaning from C++17 onward
// Historical usage - avoid in new code
int sum_array(const int* arr, int n) {
register int sum = 0; // deprecated hint
for (int i = 0; i < n; ++i) {
sum += arr[i];
}
return sum;
}
register is reserved but has no semantic effect in C++17 and later.register still prevents taking the address of the variable.register in new C++ code.registerint 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;
}