• The “this” pointer is passed as a hidden argument to all non-static member function calls and is available as a local variable within the body of all non-static functions.
  • “this” pointer is not available in static member functions as static member functions can be called without any object (with class name).
  • “this” pointer is a r-value(prvalue expression)
  • delete this; destroy the object itself
  • return *this; 常用來讓 member function 回傳自身的 reference
#include <iostream>
 
struct A {
    void printAddress() {std::cout << (void*)this << std::endl;}
};
 
int main() {
    A a;
    std::cout << (void*)(&a) << std::endl;
    a.printAddress();
    return 0;
}

Reference