We all know that a const variable needs to be initialized at the time of declaration. Then how come the program given below runs properly even when we have not initialized p?



We all know that a const variable needs to be initialized at the time of declaration. Then how come ..

Answer / Pushpendra Kumar Chahal

In C++, if a const variable is declared within a function, it does not need to be initialized at the time of declaration because its initial value is assumed to be garbage or unspecified. However, it must be assigned a definite value before it is used. This applies to the example where p is a local variable.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What are the unique features of C++.

1 Answers  


Is c++ a high level language?

1 Answers  


When should overload new operator on a global basis or a class basis?

1 Answers  


What are function poinetrs? where are they used?

1 Answers   CTS,


Why namespace is used in c++?

1 Answers  


How is objective c different from c++?

1 Answers  


Define 'std'.

1 Answers  


How to write a program such that it will delete itself after exectution?

3 Answers  


What are stacks?

1 Answers  


Why is the function main() special?

1 Answers  


Describe protected access specifiers?

1 Answers  


What is the purpose of template?

1 Answers  


Categories