Use the 'this' pointer. : this « Class « C++ Tutorial






#include <iostream> 
using namespace std; 
 
class MyClass { 
  int i; 
public: 
  void setI(int val) { 
    this->i = val; 
  }  
  int getI() { 
    return this->i; 
  }  
} ; 
 
int main() 
{ 
  MyClass o; 
 
  o.setI(100); 
  cout << o.getI(); 
 
  return 0; 
}
100








9.27.this
9.27.1.Use the 'this' pointer.
9.27.2.Using the this pointer
9.27.3.Returning the dereferenced this pointer
9.27.4.Cascading member function calls with the this pointer