InterviewSolution
Saved Bookmarks
| 1. |
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? #include<iostream> Void Main( ) { Const Char *p ; P = "a Const Pointer" ; Cout << P ; } |
|
Answer» The OUTPUT of the above PROGRAM is 'A CONST pointer'. This is because in this program p is declared as 'const char*' which means that VALUE stored at p will be constant and not p and so the program works properly. The output of the above program is 'A const pointer'. This is because in this program p is declared as 'const char*' which means that value stored at p will be constant and not p and so the program works properly. |
|