what is the function of 'this' operator ?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the realtime excercises in C++?

2341


is there any choice in opting subjects like 4 out of 7

1739


How do you answer polymorphism?

588


What is byval and byref? What are differences between them?

1699


What does no cap mean?

600






What is difference between polymorphism and inheritance?

624


What are functions in oop?

592


Can static class have constructor?

595


What is a class and object?

602


What is abstraction and encapsulation?

583


any one please tell me the purpose of operator overloading

1976


How to use CMutex, CSemaphore in VC++ MFC

4342


Which is not an object oriented programming language?

550


write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).

1650


What is encapsulation oop?

583