What is the difference between const int *ptr and int const
*ptr???

Answers were Sorted based on User's Feedback



What is the difference between const int *ptr and int const *ptr???..

Answer / manjunath

a) const int *ptr and
b) int const *ptr


Both actually mean the same...

Read from Right to left:
for(a):-> ptr is a pointer to an integer Constant and
for(b):-> ptr is a pointer to a constant integer...

..............
int *const ptr----------> ptr is a constant pointer to an
integer...

Is This Answer Correct ?    95 Yes 26 No

What is the difference between const int *ptr and int const *ptr???..

Answer / abdul sami

'const int* ptr' means the value whose address is being
held by ptr is constant and cant be changed while
'int const *ptr' means the pointer cant be changed like it
cant be incremented or decremented although you can change
the date pointed to by ptr.

Is This Answer Correct ?    41 Yes 57 No

Post New Answer

More OOPS Interview Questions

Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)

0 Answers   Accenture,


What is polymorphism give a real life example?

0 Answers  


inheritence with example

1 Answers  


how do you handle yourself when you feel the wald is aganist you

2 Answers  


What does oop mean in snapchat?

0 Answers  






What is oops in programming?

0 Answers  


What is overriding vs overloading?

0 Answers  


what is use to destroy an object? illustrate.

5 Answers   TCS,


Write a program in c++ to read two floating point numbers and find their sum and average.

2 Answers  


Why do we use inheritance?

0 Answers  


what is virtual destructor

7 Answers   L&T, TCS,


Which is the parameter that is added to every non-static member function when it is called?

3 Answers   Accenture,


Categories