Q
What happens if a const int variable is declared in C++ without an initializer (const int k;)?
-
A
A runtime error occurs
-
B
Compilation error
-
C
k holds garbage but cannot be changed
-
D
k is set to 0
Correct Answer:
B. Compilation error
Explanation:
A const object of a non-class type must be initialized when it is declared.