What is Pointer to constant?
Submitted by: AdministratorPointer to constant points to a value that does not change and is declared as:
const type * name
type is data type
name is name of the pointer
e.g: const char *p;
pointer to constant can not be used to change the value being pointed to. Therefore:
char ch = ‘A';
const char *p = &ch;
*p = ‘B';
is not allowed. The program will throw an error.
Submitted by: Administrator
const type * name
type is data type
name is name of the pointer
e.g: const char *p;
pointer to constant can not be used to change the value being pointed to. Therefore:
char ch = ‘A';
const char *p = &ch;
*p = ‘B';
is not allowed. The program will throw an error.
Submitted by: Administrator
Read Online C++ Pointers & Functions Job Interview Questions And Answers
Top C++ Pointers & Functions Questions
☺ | Can you please explain the difference between Pointer to constant and pointer constant? |
☺ | How many minimum number of functions are need to be presented in c++? |
☺ | Explain function pointers? |
☺ | Explain pointer with examples? |
Top C Plus Plus Language Categories
☺ | C++ Pointers & Functions Interview Questions. |
☺ | C++ Operator Overloading Interview Questions. |
☺ | C++ Exception Handling Interview Questions. |
☺ | C++ Template Interview Questions. |
☺ | C++ Virtual Functions Interview Questions. |