what is the function of 'this' operator ?

Answers were Sorted based on User's Feedback



what is the function of 'this' operator ?..

Answer / sudha

"this" operator only access the current object.

Is This Answer Correct ?    41 Yes 4 No

what is the function of 'this' operator ?..

Answer / venkat

'this' is used to reffer current class variable

for example

class sample
{

int myvar=10;
void mymethod()
{
int myvar=20;
system.outprintln("The value of myvar is"+myvar)
system.outprintln("The value of myvar is"+this.myvar)
}
}


output :
20,10

Is This Answer Correct ?    39 Yes 15 No

what is the function of 'this' operator ?..

Answer / bhawna

Basically "this" opertaor is a part of instance variable
hiding,when a local variable has the same name as an
instance variable,the local variables hides the instance
variables

Is This Answer Correct ?    21 Yes 2 No

what is the function of 'this' operator ?..

Answer / walking legend

as we generally know a pointer is used to point to the
address of a particular variable and access its value.
Similarly,this is a pointer which always points to the
current object.

Is This Answer Correct ?    15 Yes 3 No

what is the function of 'this' operator ?..

Answer / madhu

'this' pointer is created when you create an object with
dynamic memory allocation. 'this' pointer will be created at
the time of object creation.
It holds the current object's address.
'this' cannot be used inside the static or a friend functions.

Is This Answer Correct ?    14 Yes 2 No

what is the function of 'this' operator ?..

Answer / sohaibx

it is an implicit pointer holding the address of current object.

Is This Answer Correct ?    5 Yes 0 No

what is the function of 'this' operator ?..

Answer / sourav

Hi Venkat,
In your coding example the concept of this pointer is
fine, but can u pls tell me the where the object is getting
formed ?

Is This Answer Correct ?    7 Yes 9 No

Post New Answer

More OOPS Interview Questions

What are the advantages of polymorphism?

0 Answers  


What is virtual class and friend class?

5 Answers   IBS, Intel, Wipro,


what is different between oops and c++

0 Answers   IIT,


What exactly is polymorphism?

0 Answers  


design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)

0 Answers   UBS,






Why is polymorphism important in oop?

0 Answers  


How do you make derived class as an abstract class?

1 Answers   Convergys, TCS,


#include <string.h> #include <stdio.h> #include <stdlib.h> #include<conio.h> void insert(char *items, int count); int main(void) { char s[255]; printf("Enter a string:"); gets(s); insert(s, strlen(s)); printf("The sorted string is: %s.\n", s); getch(); return 0; } void insert(char *items, int count) { register int a, b; char t; for(a=1; a < count; ++a) { t = items[a]; for(b=a-1; (b >= 0) && (t < items[b]); b--) items[b+1] = items[b]; items[b+1] = t; } } design an algorithm for Insertion Sort

0 Answers  


What are main features of oop?

0 Answers  


What is polymorphism what are the different types of polymorphism?

0 Answers  


What is abstraction with example?

0 Answers  


What are the 5 oop principles?

0 Answers  


Categories