C++ | this

/ 26 Sept 2013 /
No not that, this...

#include <iostream>
#include <string>
using namespace std;

class Han{
 public:
  Han(int num)
  : h(num)
  {
  }
  void printCrap(){
   cout << "h = " << h << endl;
   cout << "this->h = " << this->h << endl;
   cout << "(*this).h = " << (*this).h << endl;
  }
 private:
  int h;
};

int main() {
 Han ho(23);
 ho.printCrap();
}
 
Copyright © 2010 M(ath)+me, All rights reserved