--%>

"this" pointer is different from a pointer to an object

Q. What is "this" pointer? Explain how is this is different from a pointer to an object?

 

Ans. This: This is variable that refers to the object that has called the member function. This variable is available in all the methods of the class. This is created automatically so we do not need to decide this variable.

 

Example

Class memory

{

Private Int rs;

Private Int paisa;

Public void set (int rs, Int paisa)

{

This. rs = rs;

This . paisa = paisa;

}

Public void set (Int rs, Int paisa)

{

Rs = rs;

Paisa = paisa;

}

*/

Note: If we comment out this x has been and put restriction on code y to execute, there will be default value in the field. if we create an object of this money class outside the money then, this pointer exists in that particular class only and a pointer to an object can exist in outside classes also. 

   Related Questions in Programming Languages

  • Q : Ways in which Java program is less

    Give two ways in which a Java program is less likely to be compromised than the same program written in C++.

  • Q : What is Virtual desktop Virtual desktop

    Virtual desktop: The name employed to explain a user's graphical working area in a window manager. The name arises in the early days of graphical user interfaces whenever it was thought that such would lead to `paperless offices'. This was anticipated

  • Q : What is Primitive Type Casting

    Primitive Type Casting: C/C++ allows you to cast between totally unrelated types. This can be problematic for model checking. Avoid type casting between unrelated types and in particular primitive types. For example,

    Q : Passing by address or reference Passing

    Passing by address or reference: In this technique no separate memory build for formal variables that is, formal variables share similar location of actual variables and therefore any change on formal variables automatically reflected back to real var

  • Q : Define Function Function : The name

    Function: The name given to assembly of statements which does some particular task and might return a value. Function can be invoked (or called) any number of time and anywhere in the program.

  • Q : Grade someone activities Normal 0 false

    Normal 0 false false

  • Q : State the term Win32 State the term

    State the term Win32. Answer: Win32 considers to Microsoft 32 bit Windows API. Applications of Win32 are programs that are built along with the Win32 API.

  • Q : What is validating parser What is

    What is validating parser? Answer: A parser makes sure that an XML document is valid additionally to being well formed.

  • Q : Differences between logical and

    What are the differences between logical and physical address spaces?

  • Q : What is Datagram Datagram : It is a

    Datagram: It is a packet of information passed between the two communicating procedures across a network. Both the Transmission Control Protocol (abbreviated as TCP) and the User Datagram Protocol (abbreviated as UDP) are indirectly comprised in sendi