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

Question: 1 / 565

What is the effect of defining a local variable inside a function as const?

It's a compile-time constant

It prevents changing the variable inside the function

Defining a local variable inside a function as const prevents the variable from being changed inside the function. Option A is incorrect because a compile-time constant refers to a value that cannot be changed during compilation, not just within a function. Option C is incorrect because making the function const refers to the function itself, not the local variable inside it. Option D is incorrect because const does not ensure initialization, it only prevents reassignment.

Get further explanation with Examzify DeepDiveBeta

It makes the function const

It ensures the variable is initialized at runtime

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy