Code Examples
  Home arrow Code Examples arrow Page 2 - SatView: Pointer Perfect, Part 2: Construc...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

SatView: Pointer Perfect, Part 2: Construction / Destruction
By: J. Nakamura
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 22
    2004-12-06

    Table of Contents:
  • SatView: Pointer Perfect, Part 2: Construction / Destruction
  • The This Pointer
  • Copying Pointers vs. Copying Memory
  • Pointer Pointers

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    SatView: Pointer Perfect, Part 2: Construction / Destruction - The This Pointer


    (Page 2 of 4 )

    Every object in C++ has a hidden parameter also known as the this pointer. It points to the instantiated class (object) and was therefore appropriately named "this". The compiler inserts this pointer implicitly in your code when you are accessing members and functions of an object.

    MyClass::foo() {
    myVar = 20;
    }

    can therefore be read as

    MyClass::foo() {
    this->myVar = 20;
    }

    You will also encounter the this pointer when writing the assignment operator for a class:

    MyClass& MyClass::operator =(MyClass const &rhs) {
    if (&rhs != this)
    myVar = rhs.myVar;
    return *this;
    }

    Note how the reference operator on the this pointer used in the return statement, returns a reference of that very same object!

    More Code Examples Articles
    More By J. Nakamura


     

    CODE EXAMPLES ARTICLES

    - Handling Animations and Bitmaps Using GDI+ f...
    - Download a Web Page using the WebClient
    - Creating a Chart using Data from a Database ...
    - The Basics of Charting with the MS Chart Con...
    - Searching Body Text with textRange: Enter th...
    - Searching Body Text with textRange: Building...
    - Searching Body Text with textRange, part 1: ...
    - First Steps in Programming
    - Programming in C
    - Quick Introduction to ASF,ASX, and Networkin...
    - SatView: Pointer Perfect, Part 2: Constructi...
    - SatView: Pointer Perfect, Part 1
    - Style Case Studies: Construction Unions
    - Creating an Engine for Games for Windows
    - Style Case Studies: Generic Callbacks





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT