Using this pointer referring to data - C++ Class

C++ examples for Class:this

Description

Using this pointer referring to data

Demo Code

#include <iostream>
using namespace std;
class what//from  w  w w.  java  2  s  .  c  o  m
{
   private:
   int alpha;
   public:
   void tester()
   {
      this->alpha = 11;     //same as alpha = 11;
      cout << this->alpha;  //same as cout << alpha;
   }
};
int main()
{
   what w;
   w.tester();
   cout << endl;
   return 0;
}

Result


Related Tutorials