1 / 10

This Pointer In C | This Pointer In C With Example Program | Pointers In C

In this presentation on This pointer in C , we will cover what is This pointer and the working of this pointer in C . You will also learn how to access the executing object using This pointer in C . You will get an idea about the features of This pointer in C with example program. We will also do some hands-on examples on this pointers in C .<br><br>Below topics are covered in this presentation:<br>1. What is This pointer?<br>2. Syntax of This pointer<br>3. Working of This pointer<br>4. Accessing This pointer<br>5. Applications of This pointer

Simplilearn
Télécharger la présentation

This Pointer In C | This Pointer In C With Example Program | Pointers In C

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What is This pointer?

  2. What is This pointer? What’s in it for you ? What is this pointer ? Syntax of this pointer Working of this pointer Accessing the executing object using this pointer Features of this pointer

  3. What is This pointer? In C++, This is a keyword that is used to represent an object that invokes the member functions. It automatically points to the object for which the object is being called. .

  4. What is This pointer? Click here to watch the video

  5. Syntax of This pointer Syntax for referring instance variable: this->class_variable = value; Syntax for referring to current object of class : this*

  6. Working of This pointer This keyword represents the address of the current instance of the class. The this pointer acts as an implicit(not in a direct way) parameter to all the member functions and is automatically passed to the member function when it is called.

  7. Accessing the executing object using this keyword #include<iostream> using namespace std; class O { public: void display() { cout<<"The address of object is : "; cout<< this; } }; int main() { O obj; obj.display(); return 0; }

  8. Features of this pointer distinguish data members members from local variables One of the features of this pointer is that it makes the members of the class readable by distinguishing between the class members and the parameters with the same name. void Set(int var) { this->var=var; }

  9. Features of this pointer Method chaining in C++ Method chaining is a very useful feature of this pointer. It helps in chaining the methods together for ease and cleaner code. Example: Obj->set(8)->replace(9)->inc(12);

More Related