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 is the important feature of inheritance?

725


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

6245


How to call a non virtual function in the derived class by using base class pointer

5568


What is polymorphism oop?

703


What does and I oop mean?

708






What is object and class in oops?

681


Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.

2674


Is enum a class?

687


What are the 5 oop principles?

692


program for insertion ,deletion,sorting in double link list

2358


Why is destructor used?

675


How do you define a class in oop?

730


Can a destructor be called directly?

689


What is polymorphism what is it for and how is it used?

648


Describe these concepts: Polymorphism, Inheritance and Abstraction.

702