how the this class pointer works : this « Class « C++






how the this class pointer works

  
#include <iostream>  

using namespace std;

class MyClass {  
  int i;  
public:  
  void load_i(int val) { this->i = val; }
  int get_i(void) { return this->i; } 
};  

main(void){  
  MyClass o;  

  o.load_i(100);
  cout << o.get_i();

  return 0;  
}
  
    
  








Related examples in the same category

1.this points yourself
2.Using the this pointer to refer to object members.