wats the diference btwen constant pointer and pointer to a
constant.pls give examples.
Answer Posted / monika sethi
CONSTANT POINTER: A pointer will always point to one
object.it is initialized at the time of declaration.
e.g
int i=20,j;
int* const p=&i;
cout<<*p; //will print 20
*p=30;//works....i.e the value pointed by the constant
pointer can be changed
//now if write
p=&j;//error
POINTER TO CONSTANT
it can be declared as
const int *p;
or
int const *p;
int i=10,j=30;
p=&i;
cout<<*p;
*p=10//error...the value is constant pointed by p
//pointer p is not constant so it can now point to another
variable of integer type
//so if we write
p=&j //it will now point to a variable j
that's all.........
Is This Answer Correct ? | 27 Yes | 0 No |
Post New Answer View All Answers
exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above
Can you think of a logic behind the game minesweeper.
What is the collection of communication lines and routers called?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
Why do we use int main?
Explain what is the general form of a c program?
How can I use a preprocessorif expression to ?
What are header files why are they important?
What are variables c?
What are the properties of union in c?
What are enumerated types?
What is n in c?
What does 3 mean in texting?
What is a string?
What are file streams?