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
Explain two-dimensional array.
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
Is that possible to add pointers to each other?
provide an example of the Group by clause, when would you use this clause
What does %2f mean in c?
Explain what’s a signal? Explain what do I use signals for?
Is r written in c?
Explain how can I write functions that take a variable number of arguments?
What is a list in c?
Explain the meaning of keyword 'extern' in a function declaration.
Explain how do you search data in a data file using random access method?
in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above
What is the purpose of main( ) in c language?
Can you think of a logic behind the game minesweeper.