1.

What should be done to prevent changes that may be made to the values pointed by the pointer?(a) Usual pointer can’t change the values pointed(b) Pointer should be made virtual(c) Pointer should be made anonymous(d) Pointer should be made constI have been asked this question by my school principal while I was bunking the class.Query is from Pointer to Objects in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

Right ANSWER is (d) Pointer should be MADE const

The explanation: The pointer should be declared as a const type. This prevents the pointer to change any value that is being pointed from it. This is a feature that is made to access the VALUES USING pointer but to make sure that pointer doesn’t change those values accidently.



Discussion

No Comment Found

Related InterviewSolutions