Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. "This" reference?

"This" reference?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wow9999
    wrote on last edited by
    #1

    Dear all Can someone tell me how to use "This" point, and what "This" is ? Thanks

    A J 2 Replies Last reply
    0
    • W wow9999

      Dear all Can someone tell me how to use "This" point, and what "This" is ? Thanks

      A Offline
      A Offline
      Anders Molin
      wrote on last edited by
      #2

      this is a pointer to the class in which the current function is a member. - Anders Money talks, but all mine ever says is "Goodbye!"

      1 Reply Last reply
      0
      • W wow9999

        Dear all Can someone tell me how to use "This" point, and what "This" is ? Thanks

        J Offline
        J Offline
        Jambolo
        wrote on last edited by
        #3

        Here are some examples of when this is used: 1. Sometimes you will see it as a function parameter. For example, registering a callback: Server::RegisterCallback( this ); 2. It is used for a lot of overloaded operators: Vector const & operator +( Vector const & b ) { ... return *this; } 3. When overloading operator= you must make sure that the source is not the same as the destination: Vector const & operator =( Vector const & b ) { if ( this != &b ) { ... } return *this; } You will probably never see "this->" because there is never a need for it -- it is automatic.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups