1.

Which syntax doesn’t execute/is false when executed?(a) if(&object != this)(b) if(&function !=object)(c) this.if(!this)(d) this.function(!this)The question was posed to me in my homework.I would like to ask this question from This Pointer topic in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

The correct OPTION is (a) if(&object != this)

Explanation: The condition becomes false when EXECUTED and hence doesn’t executes. This is the case where this pointer can GUARD itself from the self-reference. Here if the ADDRESS of the object doesn’t match with this pointer that means the object doesn’t refer itself.



Discussion

No Comment Found

Related InterviewSolutions