1.

Which is the correct syntax for declaring the type of this in a member function?(a) classType [cv-qualifier-list] *const this;(b) classType const[cv-qualifier-list] *this;(c) [cv-qualifier-list]*const classType this;(d) [cv-qualifier-list] classType *const this;The question was asked by my school principal while I was bunking the class.This is a very interesting question from This Pointer topic in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

Right choice is (d) [cv-qualifier-list] classType *const this;

Easy explanation - The syntax contains the cv-qualifier-list that can be determined from the member function DECLARATORY that can be either const or VOLATILE or can be made both. Hence we write it as list. classType denotes the name of class to MENTION to which class does the OBJECT BELONG to. And *const this denotes that the this pointer is having a constant value.



Discussion

No Comment Found

Related InterviewSolutions