Ace Your C++ Skills 2025 – Rock the ‘Thinking in C++’ Challenge!

Question: 1 / 565

What C++ keyword is used to ensure a variable retains its value between function calls?

const

static

A const keyword is used to designate a variable as constant and its value cannot be changed. This would not retain the variable's value between function calls.

A volatile keyword is used for variables whose value can be changed by external factors and is used for multithreading purposes but would not ensure value between function calls.

A register keyword is used to suggest to the compiler to store a variable in a register for optimization but does not ensure the value between function calls.

A static keyword is used to retain the value of a variable between function calls and is the correct answer.

Get further explanation with Examzify DeepDiveBeta

volatile

register

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy